Class RoutingServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- pl.edu.icm.unity.engine.api.utils.RoutingServlet
-
- All Implemented Interfaces:
java.io.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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CURRENT_DESTINATION
-
Constructor Summary
Constructors Constructor Description RoutingServlet(java.lang.String defaultTarget)
-
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(java.lang.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
-
-
-
-
Method Detail
-
service
protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
service
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
java.io.IOException
-
forwardTo
public static void forwardTo(java.lang.String newDestination, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException
The routing will be reconfigured to forward all requests to the given destination.- Parameters:
newDestination
-req
-resp
-- Throws:
javax.servlet.ServletException
java.io.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
-
-
-