IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.cs.servlet
Class CSReqServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.ibm.btt.cs.servlet.CSReqServlet
All Implemented Interfaces:
ChannelDriver, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
CSEstablishSessionServlet, CSReqProtocolServlet

public class CSReqServlet
extends javax.servlet.http.HttpServlet
implements ChannelDriver

The CSReqServlet implements the ChannelDriver interface to define the front door for all devices supporting the HTTP protocol. For this example, the parent context for allworkstation contexts is the "root" context.

This class implements HTTP specific behavior for saving the information associated with a session into a database using the HttpSession class supplied by WebSphere Application Server. To use the data persistence you must set the value of the tag "channelHandlers.html.requestHandler" of the dse.ini file to:

com.ibm.btt.cs.html.ext.PersistHtmlRequestHandler

It is also possible to specify whether session affinity exists using the initialization.sessionAffinity tag in the dse.ini file. By default, session affinity is assumed. To specify that there is no session affinity, set the tag's value to "no" (or "false", or "0", or "disable" ). To use this feature, you must activate the persistence of the session in the WebSphere Application Server. For more information, see the WebSphere documentation.

See Also:
Serialized Form

Field Summary
protected static java.util.ResourceBundle javaClientException
           
protected static java.util.ResourceBundle javaClientTrace
          Trace File for NLS
 
Constructor Summary
CSReqServlet()
          CSServlet constructor.
 
Method Summary
 ChannelContext createChannelContext(java.lang.Object req, java.lang.Object res, java.lang.Object driver)
          Creates a ChannelContext object with the req, res, and driver attributes.
 void createChannelHandler(ChannelContext channelContext)
          Creates a ChannelHandler object with the channelContext attribute and caches the ChannelHandler into the HandlerRegistry singleton.
protected  void getDeviceType(ChannelContext channelContext)
          Determines the device type for the handler and adds to the ChannelContext object.
protected  PresentationHandler getPresentationHandler(ChannelContext channelContext)
          Determines the PresentationHandler to invoke for the specific channel driver and obtains the presenation handler from the HandlerRegistry.
protected  RequestHandler getRequestHandler(ChannelContext channelContext)
          Determines the RequestHandler to invoke for the specific channel driver and obtains the request handler from the HandlerRegistry.
protected  void handleException(ChannelContext channelContext, java.lang.Exception ex)
          Invokes the presentation handler to pass the exception to the client.
protected  void handleException(java.lang.Exception ex)
          Logs the exception with the framwework trace facility.
protected  void handleServerResponse(ChannelContext channelContext, java.lang.Exception e)
          Convenience method to ensure that a response is returned to the client for the case where no presentation handler exists or because the server is not initialized.
 void parseRequestData(ChannelContext channelContext)
          Parses the contents of the parameters contained in the HttpServletRequest, parses the request data into the KeyedCollection, and adds the kColl into the ChannelContext request data.
 void parseRequestHeader(ChannelContext channelContext)
          Parses the contents of the header contained in the HttpServletRequest, parses the request header into the KeyedCollection, and adds the kColl into the ChannelContext request data.
 void preProcessRequest(ChannelContext channelContext)
          Performs any session management/control required at the device level.
protected  boolean runInSession(ChannelContext channelContext)
          Determines from the HandlerRegistry whether the device type should run in a session.
protected  void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Defines the process flow to execute a request.
protected  void updateChannelHandler(ChannelHandler ch, java.lang.String key, java.lang.String value)
          Performs special processing for the channel specific parameters in the server dse.ini file to instantiate the instances of the PresentationHandler and RequestHandler.
protected  boolean usingCookies(ChannelContext channelContext)
          Determines from the HandlerRegistry whether the device type is using cookies to manage the session.
 
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 Detail

javaClientTrace

protected static java.util.ResourceBundle javaClientTrace
Trace File for NLS


javaClientException

protected static java.util.ResourceBundle javaClientException
Constructor Detail

CSReqServlet

public CSReqServlet()
CSServlet constructor.

Method Detail

createChannelContext

public ChannelContext createChannelContext(java.lang.Object req,
                                           java.lang.Object res,
                                           java.lang.Object driver)
Creates a ChannelContext object with the req, res, and driver attributes. The parameters are passed as objects to support all potential channel drivers.

Specified by:
createChannelContext in interface ChannelDriver
Parameters:
req - java.lang.Object
res - java.lang.Object
driver - java.lang.Object
Returns:
com.ibm.btt.clientserver.ChannelContext - An instance of ChannelContext.

createChannelHandler

public void createChannelHandler(ChannelContext channelContext)
                          throws java.lang.Exception
Creates a ChannelHandler object with the channelContext attribute and caches the ChannelHandler into the HandlerRegistry singleton. This method instantiates the RequestHandler, PresentationHandler, and a Hashtable to contain all variable parameters located in the dse.ini file. This should only be performed the first time that the channel is accessed.

Specified by:
createChannelHandler in interface ChannelDriver
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

getDeviceType

protected void getDeviceType(ChannelContext channelContext)
                      throws DSENoRegisteredDeviceTypeException
Determines the device type for the handler and adds to the ChannelContext object. The default implementation uses the "User-Agent" tag in the Http request header to identify the handler used for this kind of client device. A section named "devices" in DSE.INI file maps the relationship between the "User-Agent" and the channel handler.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
DSENoRegisteredDeviceTypeException

getPresentationHandler

protected PresentationHandler getPresentationHandler(ChannelContext channelContext)
                                              throws DSENoRegisteredPresentationHandlerException
Determines the PresentationHandler to invoke for the specific channel driver and obtains the presenation handler from the HandlerRegistry.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Returns:
com.ibm.btt.clientserver.PresenationHandler
Throws:
DSENoRegisteredRequestHandlerException
DSENoRegisteredPresentationHandlerException

getRequestHandler

protected RequestHandler getRequestHandler(ChannelContext channelContext)
                                    throws DSENoRegisteredRequestHandlerException
Determines the RequestHandler to invoke for the specific channel driver and obtains the request handler from the HandlerRegistry.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Returns:
com.ibm.btt.clientserver.RequestHandler
Throws:
DSENoRegisteredRequestHandlerException

handleException

protected void handleException(ChannelContext channelContext,
                               java.lang.Exception ex)
Invokes the presentation handler to pass the exception to the client. This method tests to ensure that the server is started and the channel context has a device type.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
ex - java.lang.Exception Thrown if the server is unable to process a response

handleException

protected void handleException(java.lang.Exception ex)
Logs the exception with the framwework trace facility.

Parameters:
ex - java.lang.Exception

handleServerResponse

protected void handleServerResponse(ChannelContext channelContext,
                                    java.lang.Exception e)
                             throws java.lang.Exception
Convenience method to ensure that a response is returned to the client for the case where no presentation handler exists or because the server is not initialized. By default, this implementation of the channel driver is trying to reply to an HTML client. Extensions of this driver that handle channels other than HTML should implement this method to reply with a channel compliant mechanism.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
e -
Throws:
java.lang.Exception - The exception description.

parseRequestData

public void parseRequestData(ChannelContext channelContext)
                      throws java.lang.Exception
Parses the contents of the parameters contained in the HttpServletRequest, parses the request data into the KeyedCollection, and adds the kColl into the ChannelContext request data.

Override this method to modify the the data parsing behavior.

Specified by:
parseRequestData in interface ChannelDriver
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

parseRequestHeader

public void parseRequestHeader(ChannelContext channelContext)
                        throws java.lang.Exception
Parses the contents of the header contained in the HttpServletRequest, parses the request header into the KeyedCollection, and adds the kColl into the ChannelContext request data.

Override this method to modify the the data parsing behavior.

Specified by:
parseRequestHeader in interface ChannelDriver
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

preProcessRequest

public void preProcessRequest(ChannelContext channelContext)
                       throws DSECSSessionNotEstablishedException
Performs any session management/control required at the device level. This method inserts the channel session into the ChannelContext and must provide support for using cookies and hidden form field to manage the session.

Specified by:
preProcessRequest in interface ChannelDriver
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
DSECSSessionNotEstablishedException - Thrown if the session has expired

runInSession

protected boolean runInSession(ChannelContext channelContext)
                        throws DSECSSessionNotEstablishedException
Determines from the HandlerRegistry whether the device type should run in a session. Running in a session requires that the application have a valid session and the operation has a parent context. The default is to always run in a session to support backwards compatibility. If the request is to run outside of a session, this method adds "dse_ignore" to the application ID.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Returns:
boolean - Returns true to run in a session
Throws:
DSECSSessionNotEstablishedException

service

protected void service(javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res)
                throws javax.servlet.ServletException,
                       java.io.IOException
Defines the process flow to execute a request. This method is the entry point for each request coming to this servlet. note This method is valid for requests sent using the GET method and requests sent using the POST method.

Parameters:
req - HttpServletRequest
res - HttpServletResponse
Throws:
javax.servlet.ServletException
java.io.IOException

updateChannelHandler

protected void updateChannelHandler(ChannelHandler ch,
                                    java.lang.String key,
                                    java.lang.String value)
                             throws java.lang.Exception
Performs special processing for the channel specific parameters in the server dse.ini file to instantiate the instances of the PresentationHandler and RequestHandler. All other parameters are added to a Hashtable.

Parameters:
ch - com.ibm.btt.clientserver.ChannelHandler
key - java.lang.String
value - java.lang.String
Throws:
java.lang.Exception

usingCookies

protected boolean usingCookies(ChannelContext channelContext)
Determines from the HandlerRegistry whether the device type is using cookies to manage the session. The default is to not use cookies to support backwards compatibility.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Returns:
boolean - Returns true if the device is using cookies

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005