The IlvManagerServletSupport class

The IlvManagerServlet class used in the XML Grapher example gives an easy way to create a servlet that supports the Rogue Wave® JViews JavaScript Web application protocol. Using the IlvManagerServlet class is an easy way to create a servlet but has one main drawback. You cannot add the support for the Rogue Wave JViews JavaScript Web application protocol to an existing servlet since the IlvManagerServlet class derives from the HttpServlet class. The IlvManagerServletSupport class allow you to do this. This class has the same API as the IlvManagerServlet but is not a servlet (that is, it does not derive from the HttpServlet class). You can thus create your own servlet and an instance of the IlvManagerServlet support class in this servlet to handle the requests coming from the Rogue Wave JViews client side.

Web application support in the XML Grapher example

In the XML Grapher example, the code of the servlet can be rewritten using the IlvManagerServletSupport class as follows:
package demo.xmlgrapher.servlet;

import javax.servlet.*;
import javax.servlet.http.*;

import java.net.*;
import java.io.*;
import ilog.views.*;
import ilog.views.servlet.*;

import demo.xmlgrapher.*;

public class XmlGrapherServlet extends HttpServlet
{
  IlvManagerServletSupport servletSupport ;

  class MySupport extends IlvManagerServletSupport {

    private XmlGrapher xmlGrapher;

    public MySupport(ServletConfig config) {
      super();
      xmlGrapher = new XmlGrapher();
      
      String xmlfile = config.getInitParameter("xmlfile");
      
      if (xmlfile == null) 
        xmlfile = config.getServletContext().getRealPath("/data/world.xml");
      
      try {
        xmlGrapher.setNetwork(new URL("file:" + xmlfile));
      } catch (MalformedURLException ex) {
      }
      
      setVerbose(true);  
    }
    
    public IlvManagerView getManagerView(HttpServletRequest request) 
      throws ServletException {
        return xmlGrapher;
      }
    
    protected float getMaxZoomLevel(HttpServletRequest request,
                                    IlvManagerView view) {
      return 30;
    }
  }

  /**
   * Initializes the servlet.
   */
  public void init(ServletConfig config) throws ServletException {
    servletSupport = new MySupport(config);
  }

  public void doGet(HttpServletRequest request, 
                    HttpServletResponse response)
    throws IOException, ServletException {
    if (!servletSupport.handleRequest(request, response))
      throw new ServletException("unknown request type");
  }

  public void doPost(HttpServletRequest request,
                     HttpServletResponse response)
       throws IOException, ServletException {
    doGet(request, response);
  }

}
This code creates a new servlet class, XmlGrapherServlet, that derives directly from the HttpServlet class. The doGet method passes the requests to an instance of the IlvManagerServletSupport class.

Specifying fixed zoom levels on the client side

Override the following method of the IlvManagerServletSupport class to specify the zoom levels that must be used on the client side:
public double[] getZoomLevels(HttpServletRequest request, IlvManagerView view)
In this case, the maximum zoom level is not used.