Class SwitchingQueryServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class SwitchingQueryServlet
    extends javax.servlet.http.HttpServlet
    The switching servlet dispatches an incoming request to a specific web resource depending on the reslcass parameter. At initialization time, the servlet reads each initialization parameter and treats it as a resclass-to-web resource (by path) mapping. It saves each mapping. Then, for any GET or POST request, it looks for the resclass parameter and finds the corresponding web resource path. It then fowards the request to that resource, but without the resclass parameter.

    If the resclass parameter is missing or is empty, the result is a 400 (bad request). If the web resource is missing from the web server, the result is a 404 (not found).

    Version:
    $Revision$
    Author:
    Kelly
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doGet​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)  
      void doIt​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      Examine the resclass parameter and forward to the mapped web context resource.
      void doPost​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)  
      void init​(javax.servlet.ServletConfig config)
      Initialize the resource mappings.
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
    • Constructor Detail

      • SwitchingQueryServlet

        public SwitchingQueryServlet()
    • Method Detail

      • init

        public void init​(javax.servlet.ServletConfig config)
                  throws javax.servlet.ServletException
        Initialize the resource mappings. Each init parameter maps a resclass to a web context resource.
        Specified by:
        init in interface javax.servlet.Servlet
        Overrides:
        init in class javax.servlet.GenericServlet
        Parameters:
        config - a ServletConfig value.
        Throws:
        javax.servlet.ServletException - if an error occurs.
      • doGet

        public void doGet​(javax.servlet.http.HttpServletRequest req,
                          javax.servlet.http.HttpServletResponse res)
                   throws javax.servlet.ServletException,
                          IOException
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • doPost

        public void doPost​(javax.servlet.http.HttpServletRequest req,
                           javax.servlet.http.HttpServletResponse res)
                    throws javax.servlet.ServletException,
                           IOException
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • doIt

        public void doIt​(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws javax.servlet.ServletException,
                         IOException
        Examine the resclass parameter and forward to the mapped web context resource.
        Parameters:
        req - a HttpServletRequest value.
        res - a HttpServletResponse value.
        Throws:
        javax.servlet.ServletException - if an error occurs.
        IOException - if an error occurs.