com.ora.jsp.servlets
Class PBDispatcherServlet
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--com.ora.jsp.servlets.PBDispatcherServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class PBDispatcherServlet
- extends javax.servlet.http.HttpServlet
This class acts as a controller for the Project Billboard
example, dispatching to separate Action objects for request
processing.
- Version:
- 1.0
- Author:
- Hans Bergsten, Gefion software
- See Also:
- Serialized Form
Field Summary |
private java.util.Hashtable |
actions
|
Fields inherited from class javax.servlet.http.HttpServlet |
HEADER_IFMODSINCE, HEADER_LASTMOD, LSTRING_FILE, lStrings, METHOD_DELETE, METHOD_GET, METHOD_HEAD, METHOD_OPTIONS, METHOD_POST, METHOD_PUT, METHOD_TRACE |
Fields inherited from class javax.servlet.GenericServlet |
config |
Method Summary |
void |
destroy()
Removes the EmployeeRegistryBean and NewsBean
servlet context attributes. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Performs the same processing as for a POST request. |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Locates the Action object corresponding to the requested
action, or the login Action in case the user is not yet
authenticated, and dispatch the processing to the selected
Action object. |
void |
init()
Creates the application scope objects used by the Actions
and JSP pages in this application. |
private void |
initActions()
Initializes the set of Action objects used by the
application. |
private boolean |
isAuthenticated(javax.servlet.http.HttpServletRequest request)
Returns true if the session contains the authentication token. |
Methods inherited from class javax.servlet.http.HttpServlet |
, doDelete, doHead, doOptions, doPut, doTrace, getAllDeclaredMethods, getLastModified, maybeSetLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
actions
private java.util.Hashtable actions
PBDispatcherServlet
public PBDispatcherServlet()
init
public void init()
throws javax.servlet.ServletException
- Creates the application scope objects used by the Actions
and JSP pages in this application.
Note! In this example, a DataSource object is created using
hardcoded information. In a real application, it should be
retrieved through JNDI or created based on configurable
information if JNDI is not used. If the application contains
more than one servlet, it may also be better to do all
initialization in a servlet dedicated to setting up the
application environment instead.
- Overrides:
init
in class javax.servlet.GenericServlet
destroy
public void destroy()
- Removes the EmployeeRegistryBean and NewsBean
servlet context attributes.
- Overrides:
destroy
in class javax.servlet.GenericServlet
doGet
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
- Performs the same processing as for a POST request.
- Overrides:
doGet
in class javax.servlet.http.HttpServlet
doPost
public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
- Locates the Action object corresponding to the requested
action, or the login Action in case the user is not yet
authenticated, and dispatch the processing to the selected
Action object.
- Overrides:
doPost
in class javax.servlet.http.HttpServlet
initActions
private void initActions()
- Initializes the set of Action objects used by the
application. Instead of hardcoding this list, it can
be based on configuration information, such as
servlet initialization parameters.
isAuthenticated
private boolean isAuthenticated(javax.servlet.http.HttpServletRequest request)
- Returns true if the session contains the authentication token.