Class RoutingServlet

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

    public class RoutingServlet
    extends javax.servlet.http.HttpServlet
    Simple routing (dispatching) servlet. Requires a default target servlet path and can have additional servlets registered. Should be installed as an entry point for externally visible path. Subsequently it routes all requests to a current destination. The destination can be changed with a customized forward.

    Internally stores state in a single session variable.

    Author:
    K. Benedyczak
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void clean​(javax.servlet.http.HttpServletRequest req)
      Cleans any previous routing settings.
      static void forwardTo​(String newDestination, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      The routing will be reconfigured to forward all requests to the given destination.
      protected void service​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)  
      • Methods inherited from class javax.servlet.http.HttpServlet

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

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

      • CURRENT_DESTINATION

        public static final String CURRENT_DESTINATION
    • Constructor Detail

      • RoutingServlet

        public RoutingServlet​(String defaultTarget)
    • Method Detail

      • service

        protected void service​(javax.servlet.http.HttpServletRequest req,
                               javax.servlet.http.HttpServletResponse resp)
                        throws javax.servlet.ServletException,
                               IOException
        Overrides:
        service in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • forwardTo

        public static void forwardTo​(String newDestination,
                                     javax.servlet.http.HttpServletRequest req,
                                     javax.servlet.http.HttpServletResponse resp)
                              throws javax.servlet.ServletException,
                                     IOException
        The routing will be reconfigured to forward all requests to the given destination.
        Parameters:
        newDestination -
        req -
        resp -
        Throws:
        javax.servlet.ServletException
        IOException
      • clean

        public static void clean​(javax.servlet.http.HttpServletRequest req)
        Cleans any previous routing settings. Useful when a new interaction is started, but when the old session is still used.
        Parameters:
        req -