Expresso 5-6

com.jcorporate.expresso.core.controller
Class ServletControllerRequest

java.lang.Object
  extended bycom.jcorporate.expresso.core.controller.ControllerRequest
      extended bycom.jcorporate.expresso.core.controller.ServletControllerRequest
All Implemented Interfaces:
Cloneable, RequestContext, Serializable

public class ServletControllerRequest
extends ControllerRequest
implements Cloneable

ServletControllerRequest is an extension of ControllerRequest that also contains access to "special" servlet-related items, such as the ServletResponse object. It should only be used *when absolutely necessary*, as normally a standard ControllerParms object is better.

See Also:
Serialized Form

Constructor Summary
ServletControllerRequest()
          Default constructor
 
Method Summary
 Object clone()
          Method that returns a copy of itself with all the fields properly filled out.
 Servlet getCallingServlet()
          Gets the calling servlet.
 org.apache.struts.action.ActionForm getForm()
          Gets the action form as a convenience for pure Struts writer.
 HttpServletRequest getHttpServletRequest()
          Gets the http servlet response object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions.

 HttpServletResponse getHttpServletResponse()
          Gets the http servlet response object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions.

 Locale getLocale()
          Returns the locale of this request.
 org.apache.struts.action.ActionMapping getMapping()
          Gets the action mapping as a convenience for pure Struts writer.
 String[] getParamValues(String paramName)
          Fetches array of parameter values from underlying HTTP request; use this in a web app to access the underlying parameters in the HTTP request which have the same name; parameters with the same name are not reflected in the hashtable of params maintained by ControllerRequest;
 ServletRequest getServletRequest()
          Gets the servlet request object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions.

 ServletResponse getServletResponse()
          Gets the servlet response object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions.

static ServletControllerRequest parseParams(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, HttpServletRequest request, HttpServletResponse response, Controller controller)
          Parse a regular servlet request for parameters (e.g. not multipart)
static ServletControllerRequest parseParamsMultiPart(org.apache.struts.upload.MultipartRequestHandler mp, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, HttpServletRequest request, HttpServletResponse response, Controller controller)
          Static constructor for creating an servlet controller request with all the acoutrements of the Struts Action execution signature.
 void setCallingServlet(Servlet newServlet)
          Sets the calling servlet.
 void setForm(org.apache.struts.action.ActionForm newForm)
          Sets the action form as a convenience for pure Struts writer.
 void setMapping(org.apache.struts.action.ActionMapping newMapping)
          Sets the action mapping as a convenience for pure Struts writer author Peter Pilgrim
 void setServletRequest(ServletRequest newRequest)
          Sets the servlet request object
 void setServletResponse(ServletResponse newResponse)
          Sets the servlet response object
 
Methods inherited from class com.jcorporate.expresso.core.controller.ControllerRequest
getAttrib, getAttribute, getAttributes, getDataContext, getDBName, getErrorCollection, getFileName, getFormAttribute, getInitParameter, getObjectParameter, getParameter, getParameters, getSession, getUid, getUser, getUserInfo, isFileParameter, isParameter, populate, removeAttrib, removeParameter, setAttrib, setAttribute, setAttributes, setDataContext, setDBName, setFileParameter, setFormAttribute, setInitParameter, setLocale, setObjectParameter, setParameter, setParameters, setSession, setUid, setUser, validateDBField, validateDBObject, validateField
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletControllerRequest

public ServletControllerRequest()
Default constructor

Method Detail

setServletResponse

public void setServletResponse(ServletResponse newResponse)
Sets the servlet response object

Parameters:
newResponse - the new servlet response
See Also:
getServletResponse()

setServletRequest

public void setServletRequest(ServletRequest newRequest)
Sets the servlet request object

Parameters:
newRequest - the new servlet request
See Also:
getServletRequest()

setCallingServlet

public void setCallingServlet(Servlet newServlet)
Sets the calling servlet. For example an ExpressoActionServlet

Parameters:
newServlet - the new calling servlet
See Also:
getCallingServlet()

getCallingServlet

public Servlet getCallingServlet()
Gets the calling servlet. Used for creation, for example.

Returns:
javax.servlet.Servlet set previously in setCallingServlet()
See Also:
getCallingServlet()

setMapping

public void setMapping(org.apache.struts.action.ActionMapping newMapping)
Sets the action mapping as a convenience for pure Struts writer

author Peter Pilgrim

Parameters:
newMapping - the ActionMapping associated with the controller request
See Also:
getMapping()

getMapping

public org.apache.struts.action.ActionMapping getMapping()
Gets the action mapping as a convenience for pure Struts writer. The base Controller object stores the current action mapping instance in the ControllerResponse using this method. Writers who only ever intend there controller to be used in a web environment can access the action mapping to do more sophisticated processing.

 public AcmeController extends DBController {
 

protected void runProcessOrderState( ControllerRequest req, ControllerRequest res ) { ServletControllerRequest request = (ServletControllerRequest)req; ActionMapping mapping = request.getMapping();

} ... }

author Peter Pilgrim

Returns:
ActionMapping
See Also:
setMapping(org.apache.struts.action.ActionMapping)

setForm

public void setForm(org.apache.struts.action.ActionForm newForm)
Sets the action form as a convenience for pure Struts writer.

author Peter Pilgrim Fri Jan 23 23:40:14 GMT 2004

Parameters:
newForm - the ActionForm associated with the controller request
See Also:
getForm()

getForm

public org.apache.struts.action.ActionForm getForm()
Gets the action form as a convenience for pure Struts writer. The base Controller object stores the current action form instance in the ControllerResponse using this method. Writers who only ever intend there controller to be used in a web environment can access the action form to do more sophisticated processing.

 public AcmeController extends DBController {
 

protected void runProcessOrderState( ControllerRequest req, ControllerRequest res ) { ServletControllerRequest request = (ServletControllerRequest)req; ActionForm form = request.getForm();

} ... }

author Peter Pilgrim

Returns:
ActionForm
See Also:
setForm(org.apache.struts.action.ActionForm)

getServletRequest

public ServletRequest getServletRequest()
Gets the servlet request object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions. If you do access the response object, you must also call setCustomOutput(true) in the ControllResponse object to let the Controller container (ControllerServlet, ControllRun, etc) know that it should not attempt to handle view processing itself. Don't use it if you don't *need* it.

Returns:
ServletRequest object
See Also:
getServletResponse(), setServletRequest(javax.servlet.ServletRequest)

getServletResponse

public ServletResponse getServletResponse()
Gets the servlet response object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions. If you do access the response object, you must also call setCustomOutput(true) in the ControllResponse object to let the Controller container (ControllerServlet, ControllRun, etc) know that it should not attempt to handle view processing itself. Don't use it if you don't *need* it.

Returns:
ServletResponse object
See Also:
getServletRequest(), setServletResponse(javax.servlet.ServletResponse)

getHttpServletRequest

public HttpServletRequest getHttpServletRequest()
Gets the http servlet response object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions. If you do access the response object, you must also call setCustomOutput(true) in the ControllResponse object to let the Controller container (ControllerServlet, ControllRun, etc) know that it should not attempt to handle view processing itself. Don't use it if you don't *need* it.

Returns:
HttpServletRequest object
Throws:
ClassCastException - if the servlet request cannot be convert to HttpServletResponse
See Also:
getHttpServletResponse()

getHttpServletResponse

public HttpServletResponse getHttpServletResponse()
Gets the http servlet response object

Important: A Controller should only use this method if strictly necessary, and not write output that is otherwise able to be handled with inputs, outputs and transitions. If you do access the response object, you must also call setCustomOutput(true) in the ControllResponse object to let the Controller container (ControllerServlet, ControllRun, etc) know that it should not attempt to handle view processing itself. Don't use it if you don't *need* it.

Returns:
HttpServletResponse object
Throws:
ClassCastException - if the servlet request cannot be convert to HttpServletResponse
See Also:
getHttpServletRequest()

parseParamsMultiPart

public static ServletControllerRequest parseParamsMultiPart(org.apache.struts.upload.MultipartRequestHandler mp,
                                                            org.apache.struts.action.ActionMapping mapping,
                                                            org.apache.struts.action.ActionForm form,
                                                            HttpServletRequest request,
                                                            HttpServletResponse response,
                                                            Controller controller)
                                                     throws ServletException,
                                                            ControllerException
Static constructor for creating an servlet controller request with all the acoutrements of the Struts Action execution signature.

I deliberate add the ActionMapping, ActionForm beans as conveniences for Struts developers. You can probably sense I am cheesed off like Simon Cowell int American (Pop) Idol

Docu byte Peter Pilgrim Fri Jan 23 23:20:41 GMT 2004

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - the Servlet Request
response - the Servlet Response
controller - the Controller
Throws:
ControllerException - exception upon controller error
ServletException - upon javax.servlet related errors

parseParams

public static ServletControllerRequest parseParams(org.apache.struts.action.ActionMapping mapping,
                                                   org.apache.struts.action.ActionForm form,
                                                   HttpServletRequest request,
                                                   HttpServletResponse response,
                                                   Controller controller)
                                            throws ServletException,
                                                   ControllerException
Parse a regular servlet request for parameters (e.g. not multipart)

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - the Servlet Request
response - the Servlet Response
controller - the Controller
Returns:
a constructed ServletControllerRequest object
Throws:
ControllerException - exception upon controller error
ServletException - upon javax.servlet related errors

getLocale

public Locale getLocale()
Description copied from class: ControllerRequest
Returns the locale of this request.

Specified by:
getLocale in interface RequestContext
Overrides:
getLocale in class ControllerRequest
Returns:
a Locale Object based upon current locale settings.

clone

public Object clone()
Method that returns a copy of itself with all the fields properly filled out. Note that all the servletrequest/servletresponse classes are merely shallow copied since a deep copy is meaningless in a servlet environment

Overrides:
clone in class ControllerRequest
Returns:
a new instantiated ServletControllerRequest object

getParamValues

public String[] getParamValues(String paramName)
Fetches array of parameter values from underlying HTTP request; use this in a web app to access the underlying parameters in the HTTP request which have the same name; parameters with the same name are not reflected in the hashtable of params maintained by ControllerRequest;

Parameters:
paramName - key to look for among all parameters
Returns:
an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.