|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--com.iplanet.jato.ApplicationServletBase
The core JATO request handling infrastructure. This class forms the core implementation of JATO's request handling and dispatch mechanism, and includes hooks for customizing this behavior. This servlet is not invoked directly in a JATO application. Instead, developers must derive their module-specifc servlets (called module servlets) from this class. These module servlets will then customize the request handling behavior of this class by overriding the appropriate hook or event handler methods.
Field Summary | |
static java.lang.String |
APPLICATION_ERROR_MESSAGE_I18N
|
static java.lang.String |
DEVELOPER_EVENT_OVERRIDE_HELP_MESSAGE_I18N
|
static java.lang.String |
MESSAGE_AREA_POSTFIX
|
static java.lang.String |
MESSAGE_AREA_PREFIX
|
static java.lang.String |
PARAM_DEBUG
|
static java.lang.String |
PARAM_HANDLER_BEAN
|
static java.lang.String |
REQUEST_CONTEXT_ATTRIBUTE_NAME
|
static java.lang.String |
RESERVED_PARAMETER_NAME_PREFIX
|
static java.lang.String |
SHOW_MESSAGE_BUFFER_ATTRIBUTE_NAME
|
Constructor Summary | |
ApplicationServletBase()
Default constructor |
Method Summary | |
protected void |
addResponseHeaders(RequestContext requestContext)
Adds HTTP headers to the response. |
protected RequestContext |
createRequestContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Factory method that creates the request context used for the current request. |
protected void |
dispatchRequest(ViewBean viewBean,
RequestContext requestContext)
Dispatches the request to the provided view bean |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
The main entry point for HTTP GET requests. |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
The main entry point for HTTP POST requests. |
protected void |
fireAfterRequestEvent(RequestContext requestContext)
Fire the onAfterRequest event |
protected void |
fireBeforeRequestEvent(RequestContext requestContext)
Fire the onBeforeRequest event |
protected void |
fireInitializeHandlerEvent(RequestContext requestContext,
RequestHandler requestHandler)
Fire the onInitializeHandler event |
protected void |
fireNewSessionEvent(RequestContext requestContext)
Fire the onNewSession event |
protected void |
fireRequestHandlerNotFoundEvent(RequestContext requestContext,
java.lang.String handlerName)
Fire the onRequestHandlerNotFound event |
protected void |
fireRequestHandlerNotSpecifiedEvent(RequestContext requestContext)
Fire the onRequestHandlerNotSpecified event |
protected void |
fireSessionEvents(RequestContext requestContext)
|
protected void |
fireSessionTimeoutEvent(RequestContext requestContext)
Fire the onSessionTimeout event |
protected void |
fireUncaughtException(RequestContext requestContext,
java.lang.Exception e)
Fire the onUncaughtException event |
protected java.lang.String |
getDefaultHandlerName(javax.servlet.http.HttpServletRequest request)
Invoked when a handler name is not specified in the request. |
protected java.lang.String |
getLocalizedMessage(java.lang.String key)
Defensive accessor method for localized messages. |
java.lang.String |
getModuleURL()
Return the module URL for this servlet |
static java.lang.String |
getModuleURL(RequestContext context,
java.lang.Class classInModule)
Returns the module URL for the specified class in that module |
static java.lang.String |
getModuleURLParameterName(java.lang.String className)
Returns the name of the module URL servlet context parameter for a given class |
static java.lang.String |
getPackageName(java.lang.String className)
Returns the package name from the specified class name |
java.lang.String |
getServletName()
Return the servlet name specified in the ServletConfig |
protected ViewBean |
getViewBeanInstance(java.lang.String pageName,
RequestContext requestContext)
Helper method to assist in obtaining the ViewBean for the specified page name. |
void |
init(javax.servlet.ServletConfig config)
Servlet initialization method |
protected void |
initializeRequestContext(RequestContext requestContext)
Subclasses should override this method to further initialize the request context as needed. |
boolean |
isDebug()
Return the state of debug mode. |
protected boolean |
isNewSession(RequestContext requestContext)
Returns the "new" status of the current session |
protected boolean |
isSessionTimedOut(RequestContext requestContext,
java.lang.String requestedSessionID)
Returns the timeout status of the current session |
boolean |
isShowMessageBuffer()
Return whether or not the application message buffer will be appended to the rendered HTML page. |
void |
notifyRequestCompletionListeners(RequestContext requestContext)
Notifies the request completion listeners associated with the request context that the request is complete. |
protected void |
onAfterRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated. This event has been superceded by onAfterRequest(RequestContext requestContext) |
protected void |
onAfterRequest(RequestContext requestContext)
Override this method to perform actions after the request has been handled and a response page rendered. |
protected void |
onBeforeHeader(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated. This event has been removed. Migrate all code in this event to the onInitializeHandler() method. |
protected void |
onBeforeRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated. This event has been superceded by onBeforeRequest(RequestContext requestContext) |
protected void |
onBeforeRequest(RequestContext requestContext)
Override this method to perform actions before the request is dispatched to the ViewBean handler, such as checking security or
logging debug information. |
protected void |
onBeforeSessionUpdate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated. This event has been removed. Migrate all code in this event to the onAfterRequest() method. |
protected void |
onInitializeHandler(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ViewBean viewBean)
Deprecated. This event has been superceded by onInitializeHandler(RequestContext requestContext, RequestHandler requestHandler) |
protected void |
onInitializeHandler(RequestContext requestContext,
RequestHandler requestHandler)
Override this method to perform common of the ViewBean
being invoked on this request. |
protected void |
onInitializeHandler(RequestContext requestContext,
ViewBean viewBean)
Deprecated. This event has been superceded by onInitializeHandler(RequestContext requestContext, RequestHandler requestHandler) |
protected void |
onNewSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated. This event has been superceded by onNewSession(RequestContext requestContext) |
protected void |
onNewSession(RequestContext requestContext)
Override this method to receive notification of a new session (a new user has requested a page) |
protected void |
onRequestHandlerNotFound(RequestContext requestContext,
java.lang.String handlerName)
Override this method to receive notification that a request was received that specified an invalid target request handler (page). |
protected void |
onRequestHandlerNotSpecified(RequestContext requestContext)
Override this method to receive notification that a request was received that did not specify a target request handler (page). |
protected void |
onSessionTimeout(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Deprecated. This event has been superceded by onSessionTimeout(RequestContext requestContext) |
protected void |
onSessionTimeout(RequestContext requestContext)
Override this method to receive notification that a request was submitted with an exprired session. |
protected void |
onUncaughtException(RequestContext requestContext,
java.lang.Exception e)
Override this method to respond to uncaught application error messages. |
protected void |
outputDebug(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Appends a snoop-style table of diagnostic information to the bottom of the rendered HTML page. |
protected void |
outputServletErrorMessage(RequestContext requestContext,
int statusCode,
java.lang.String message,
java.lang.String detail,
java.lang.Throwable e)
|
protected java.lang.String |
parsePathInfo(java.lang.String pathInfo)
Returns the logical page name specified on the request URL |
protected java.lang.String |
prepareEventOverrideMessage(java.lang.String eventMethodName)
Prepares a localized version of the "developer friendly" event override error message |
protected java.lang.String |
prepareServletErrorMessage(java.lang.String message,
java.lang.String detail,
java.io.StringWriter stringWriter)
Prepares a localized version of the "developer friendly" servlet error message |
protected void |
processRequest(java.lang.String pageName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This method contains the main implementation of JATO's request handling and dispatch mechanism |
void |
setDebug(boolean value)
Set the state of debug mode. |
void |
setDefaultHandlerName(java.lang.String value)
Sets the default handler name to be used when a handler name isn't specified in the request |
void |
setModuleURL(java.lang.String value)
Set the module URL for this servlet |
protected void |
setProperty(javax.servlet.ServletConfig config,
java.lang.String fullPropertyName,
java.lang.Object propertyValue)
Sets the specified property on the servlet instance |
void |
setShowMessageBuffer(boolean value)
Set whether or not the application message buffer will be appended to the rendered HTML page. |
protected boolean |
showMissingModuleURLWarning()
For internal use only. |
protected void |
showMissingModuleURLWarning(boolean value)
For internal use only. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String RESERVED_PARAMETER_NAME_PREFIX
public static final java.lang.String REQUEST_CONTEXT_ATTRIBUTE_NAME
public static final java.lang.String PARAM_DEBUG
public static final java.lang.String PARAM_HANDLER_BEAN
public static final java.lang.String MESSAGE_AREA_PREFIX
public static final java.lang.String MESSAGE_AREA_POSTFIX
public static final java.lang.String SHOW_MESSAGE_BUFFER_ATTRIBUTE_NAME
public static final java.lang.String APPLICATION_ERROR_MESSAGE_I18N
public static final java.lang.String DEVELOPER_EVENT_OVERRIDE_HELP_MESSAGE_I18N
Constructor Detail |
public ApplicationServletBase()
Method Detail |
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
protected void setProperty(javax.servlet.ServletConfig config, java.lang.String fullPropertyName, java.lang.Object propertyValue) throws java.beans.IntrospectionException
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doPost()
method, as there is no difference between a
GET and POST invocation in a JATO application.doGet
in class javax.servlet.http.HttpServlet
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doGet()
method.doPost
in class javax.servlet.http.HttpServlet
protected java.lang.String parsePathInfo(java.lang.String pathInfo)
protected void processRequest(java.lang.String pageName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
protected java.lang.String getDefaultHandlerName(javax.servlet.http.HttpServletRequest request)
setDefaultHandlerName(...)
method, or null (the default).
If the returned value is null, the servlet will throw an exception
indicating that there was no specified handler.You may override this method in subclasses to provide the default handler name when an invocation is not present in the request. This value could be a default start page or an error page.
request
- The servlet request object. Implementors of this method
can use the request to gather any information they require
in order to determine the proper handler name.public void setDefaultHandlerName(java.lang.String value)
value
- The new handler name. This is the logical name of
the handler, not a class name.protected void addResponseHeaders(RequestContext requestContext)
requestContext
- The request context for the current requestprotected RequestContext createRequestContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
RequestContext
of desired.request
- The current request's request objectresponse
- The current request's response objectprotected void initializeRequestContext(RequestContext requestContext)
requestContext
- The request context for the current requestpublic void notifyRequestCompletionListeners(RequestContext requestContext)
requestContext
- The request context for the current requestprotected void fireSessionEvents(RequestContext requestContext) throws javax.servlet.ServletException
protected boolean isNewSession(RequestContext requestContext)
requestContext
- The current request's RequestContext objectprotected boolean isSessionTimedOut(RequestContext requestContext, java.lang.String requestedSessionID)
requestContext
- The current request's RequestContext objectrequestedSessionID
- The requested session ID to check for timeout. The reason
this value is passed to this method is because of a bug in
Tomcat and potentially other containers that causes the
HttpServletRequest.getRequestedSessionId()
method
to return the session ID of a newly created session instead
of the actual request session ID from the request. The value
passed in this parameter is obtained before the session is
created or any session-related events are fired, thereby
hopefully avoiding this bug.protected ViewBean getViewBeanInstance(java.lang.String pageName, RequestContext requestContext) throws javax.servlet.ServletException
initializeHandler()
event for the returned ViewBean, or the requestHandlerNotFound()
event if the ViewBean for the page is not found.protected void dispatchRequest(ViewBean viewBean, RequestContext requestContext) throws java.lang.Exception
viewBean
- The view bean that will handle the request invocation
via its invokeRequestHandler()
methodrequestContext
- The request context for the current requestprotected void outputDebug(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
request
- The servlet request object for the current requestresponse
- The servlet response object for the current requestprotected void outputServletErrorMessage(RequestContext requestContext, int statusCode, java.lang.String message, java.lang.String detail, java.lang.Throwable e) throws javax.servlet.ServletException
protected void fireNewSessionEvent(RequestContext requestContext) throws javax.servlet.ServletException
onNewSession
eventprotected void fireSessionTimeoutEvent(RequestContext requestContext) throws javax.servlet.ServletException
onSessionTimeout
eventprotected void fireBeforeRequestEvent(RequestContext requestContext) throws javax.servlet.ServletException
onBeforeRequest
eventprotected void fireRequestHandlerNotSpecifiedEvent(RequestContext requestContext) throws javax.servlet.ServletException
onRequestHandlerNotSpecified
eventprotected void fireRequestHandlerNotFoundEvent(RequestContext requestContext, java.lang.String handlerName) throws javax.servlet.ServletException
onRequestHandlerNotFound
eventprotected void fireInitializeHandlerEvent(RequestContext requestContext, RequestHandler requestHandler) throws javax.servlet.ServletException
onInitializeHandler
eventprotected final void fireAfterRequestEvent(RequestContext requestContext)
onAfterRequest
eventprotected final void fireUncaughtException(RequestContext requestContext, java.lang.Exception e) throws javax.servlet.ServletException, java.io.IOException
onUncaughtException
eventprotected void onNewSession(RequestContext requestContext) throws javax.servlet.ServletException
requestContext
- The request context for the current requestprotected void onSessionTimeout(RequestContext requestContext) throws javax.servlet.ServletException
Note that the invalidation of the session by default means that regardless of how the user accesses the application after a session timeout, the request will result in a session timeout error. This is by design, and is intended to be as strict as possible. Without this protection, if the developer did not override the default event (as we reccommend), it would be possible for the user to receive a session timeout error, but then continue though the application on the next request. Although this may be desirable behavior in some cases, this is a dangerous default, so this method always invalidates the session to ensure that the user cannot perform unintended actions after timing out. One consequence of this ehavior is that, because of the way session is tracked across requests using cookies, the user will have to close the current browser to access the application again after a session timeout occurs. To avoid this behavior, the developer must override this event and avoid invalidating the session, as described above, while ensuring that not invalidating the session on a timeout cannot cause application inconsistencies.
requestContext
- The request context for the current requestprotected void onBeforeRequest(RequestContext requestContext) throws javax.servlet.ServletException
ViewBean
handler, such as checking security or
logging debug information.requestContext
- The request context for the current requestprotected void onRequestHandlerNotSpecified(RequestContext requestContext) throws javax.servlet.ServletException
requestContext
- The request context for the current requestprotected void onRequestHandlerNotFound(RequestContext requestContext, java.lang.String handlerName) throws javax.servlet.ServletException
requestContext
- The request context for the current requesthandlerName
- The request handler nameprotected void onInitializeHandler(RequestContext requestContext, RequestHandler requestHandler) throws javax.servlet.ServletException
ViewBean
being invoked on this request.requestContext
- The request context for the current requestrequestHandler
- The request handler for the current requestprotected void onAfterRequest(RequestContext requestContext)
requestContext
- The request context for the current requestprotected void onUncaughtException(RequestContext requestContext, java.lang.Exception e) throws javax.servlet.ServletException, java.io.IOException
requestContext
- The request context for the current requeste
- The uncaught exceptionprotected final void onNewSession(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
protected final void onSessionTimeout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
protected final void onBeforeRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
protected final void onInitializeHandler(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ViewBean viewBean)
protected final void onInitializeHandler(RequestContext requestContext, ViewBean viewBean) throws javax.servlet.ServletException
protected final void onAfterRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected final void onBeforeHeader(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected final void onBeforeSessionUpdate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public java.lang.String getServletName()
ServletConfig
getServletName
in class javax.servlet.GenericServlet
public java.lang.String getModuleURL()
public void setModuleURL(java.lang.String value)
public boolean isDebug()
public void setDebug(boolean value)
public boolean isShowMessageBuffer()
public void setShowMessageBuffer(boolean value)
protected boolean showMissingModuleURLWarning()
protected void showMissingModuleURLWarning(boolean value)
public static java.lang.String getPackageName(java.lang.String className)
public static java.lang.String getModuleURLParameterName(java.lang.String className)
className
- The name of the classpublic static java.lang.String getModuleURL(RequestContext context, java.lang.Class classInModule)
context
- The request context for the current requestclassInModule
- A class in the desired module. This class is used to
derive the module URL parameter name in the servlet
context.protected java.lang.String prepareServletErrorMessage(java.lang.String message, java.lang.String detail, java.io.StringWriter stringWriter)
message
- The basic error messagedetail
- The detailed error messagestringWriter
- The stringWriter containing the stack traceprotected java.lang.String prepareEventOverrideMessage(java.lang.String eventMethodName)
eventMethodName
- The event which developers should overrideprotected java.lang.String getLocalizedMessage(java.lang.String key)
key
- The resource bundle key
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |