JViews JavaScript applications use an active locale when
searching for localized resources. The active locale is
determined by a Servlet class, which is configured in
web.xml
:
<web-app>
...
<servlet>
<servlet-name>
XmlGrapherServlet
</servlet-name>
<servlet-class>
xmlgrapher.servlet.XmlGrapherServlet
</servlet-class>
<servlet-mapping>
<servlet-name>
XmlGrapherServlet
</servlet-name>
<url-pattern>
/xmlgrapher.servlet.XmlGrapherServlet
</url-pattern>
</servlet-mapping>
...
</web-app>
As a convenience, the JViews library
already provides predefined Servlet classes for each product to
take care of both image generation and locale determination. You
only need to inherit from the corresponding Servlet class for
your application.
In the preceding example, the
XmlGrapherServlet
extends
ilog.views.servlet.IlvManagerServlet
:
public class XmlGrapherServlet extends IlvManagerServlet {...}
You can find the predefined JViews
Servlet classes in the section Servlet classes.
In the case where you want to create your own Servlet class for
locale determination, the JViews library also provides the
support class
IlvScriptMessageServletSupport. This class
gets the current locale in thread context and return
locale-specific JavaScript message files to the client. The
following code fragment shows how to use this class:
private IlvScriptMessageServletSupport _scriptMessageServletSupport=null;
public boolean handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String type = request.getParameter("request");
if (IlvScriptMessageServletSupport.REQUEST_TYPE.equals(type)) {
doGetScriptMessage(request, response);
return true;
}
...
}
private void doGetScriptMessage(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException {
if (_scriptMessageServletSupport==null) getScriptMessageSupport();
_scriptMessageServletSupport.handleRequest(request, response);
}
public IlvScriptMessageServletSupport getScriptMessageSupport() {
if (_scriptMessageServletSupport==null)
_scriptMessageServletSupport = new IlvScriptMessageServletSupport(this.getContext());
return _scriptMessageServletSupport;
}