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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
CURRENT_DESTINATION
-
Constructor Summary
Constructors Constructor Description RoutingServlet(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(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
-
-
-
-
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 classjavax.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
-
-
-