Class RoutingServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
pl.edu.icm.unity.engine.api.utils.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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RoutingServlet(String defaultTarget)
     
  • Method Summary

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CURRENT_DESTINATION

      public static final String CURRENT_DESTINATION
  • Constructor Details

    • RoutingServlet

      public RoutingServlet(String defaultTarget)
  • Method Details

    • 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 -