|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.opensymphony.webwork.dispatcher.ServletDispatcher
Main dispatcher servlet in WebWork2 which acts as the controller in the MVC paradigm.
When a request enters the servlet the following things will happen:
HttpServletResponse.SC_INTERNAL_SERVER_ERROR
error and any resource errors
(i.e., invalid action name or missing JSP page) will result in a
HttpServletResponse.SC_NOT_FOUND
error. Instead of traditional servlet init params this servlet will initialize itself using WebWork2 properties. The following properties are used upon initialization:
Integer.MAX_VALUE
will be used
(essentially unlimited so be careful).getParameterMap(HttpServletRequest)
getRequestMap(HttpServletRequest)
getSessionMap(HttpServletRequest)
getNameSpace(HttpServletRequest)
ServletDispatcherResult
,
Serialized FormField Summary | |
protected static String |
encoding
|
protected static Locale |
locale
|
protected static org.apache.commons.logging.Log |
log
Logger for this class. |
Fields inherited from interface com.opensymphony.webwork.WebWorkStatics |
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERLVET_DISPATCHER, SERVLET_CONFIG, SERVLET_DISPATCHER |
Constructor Summary | |
ServletDispatcher()
|
Method Summary | |
static HashMap |
createContextMap(Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap,
HttpServletRequest request,
HttpServletResponse response,
ServletConfig servletConfig)
Merges all application and servlet attributes into a single HashMap to represent the entire Action context. |
protected String |
getActionName(HttpServletRequest request)
Build the name of the action from the request. |
protected String |
getActionName(String name)
Determine action name by extracting last string and removing extension (i.e., /.../.../Foo.action -> Foo). |
protected Map |
getApplicationMap()
Returns a Map of all application attributes. |
static String |
getEncoding()
|
static Locale |
getLocale()
|
protected int |
getMaxSize()
Returns the maximum upload size allowed for multipart requests (this is configurable). |
protected String |
getNameSpace(HttpServletRequest request)
Gets the namespace of the action from the request. |
static String |
getNamespaceFromServletPath(String servletPath)
Returns the namespace (the context path) of the action. |
protected Map |
getParameterMap(HttpServletRequest request)
Returns a Map of all request parameters. |
protected Map |
getRequestMap(HttpServletRequest request)
Returns a Map of all request attributes. |
protected String |
getSaveDir()
Returns the path to save uploaded files to (this is configurable). |
protected Map |
getSessionMap(HttpServletRequest request)
Returns a Map of all session attributes. |
void |
init(ServletConfig servletConfig)
Initalizes the servlet. |
boolean |
isParamsWorkaroundEnabled()
|
static Locale |
localeFromString(String localeStr)
Builds a Locale from a String of the form en_US_foo into a Locale
with language "en", country "US" and variant "foo". |
protected void |
sendError(HttpServletRequest request,
HttpServletResponse response,
int code,
Exception e)
Sends an HTTP error response code. |
void |
service(HttpServletRequest request,
HttpServletResponse response)
Services the request by determining the desired action to load, building the action context and then executing the action. |
void |
serviceAction(HttpServletRequest request,
HttpServletResponse response,
String namespace,
String actionName,
Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap)
Loads the action and executes it. |
protected HttpServletRequest |
wrapRequest(HttpServletRequest request)
Wraps and returns the given response or returns the original response object. |
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, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final org.apache.commons.logging.Log log
protected static String encoding
protected static Locale locale
Constructor Detail |
public ServletDispatcher()
Method Detail |
public static String getNamespaceFromServletPath(String servletPath)
servletPath
- the servlet URL path.
public static HashMap createContextMap(Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap, HttpServletRequest request, HttpServletResponse response, ServletConfig servletConfig)
requestMap
- a Map of all request attributes.parameterMap
- a Map of all request parameters.sessionMap
- a Map of all session attributes.applicationMap
- a Map of all servlet context attributes.request
- the HttpServletRequest object.response
- the HttpServletResponse object.servletConfig
- the ServletConfig object.
public static String getEncoding()
public static Locale getLocale()
public boolean isParamsWorkaroundEnabled()
public void init(ServletConfig servletConfig) throws ServletException
class documentation
for more
detail.
init
in interface Servlet
servletConfig
- the ServletConfig object.
ServletException
- if an error occurs during initialization.public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException
This method also transparently handles multipart requests.
request
- the HttpServletRequest object.response
- the HttpServletResponse object.
ServletException
- if an error occurs while loading or executing the action.public void serviceAction(HttpServletRequest request, HttpServletResponse response, String namespace, String actionName, Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap)
sendError(HttpServletRequest,HttpServletResponse,int,Exception)
method.
request
- the HttpServletRequest object.response
- the HttpServletResponse object.namespace
- the namespace or context of the action.actionName
- the name of the action to execute.requestMap
- a Map of request attributes.parameterMap
- a Map of request parameters.sessionMap
- a Map of all session attributes.applicationMap
- a Map of all application attributes.protected String getActionName(HttpServletRequest request)
request
- the HttpServletRequest object.
protected String getActionName(String name)
name
- the full action path.
protected Map getApplicationMap()
ApplicationMap
. Override this method to customize how application attributes are mapped.
protected String getNameSpace(HttpServletRequest request)
getNamespaceFromServletPath(String)
method
with the servlet path as the parameter.
request
- the HttpServletRequest object.
protected Map getParameterMap(HttpServletRequest request) throws IOException
ServletRequest.getParameterMap()
. Override this method to customize how application parameters
are mapped.
request
- the HttpServletRequest object.
IOException
- if an exception occurs while retrieving the parameter map.protected Map getRequestMap(HttpServletRequest request)
RequestMap
. Override this method to customize how request attributes are mapped.
request
- the HttpServletRequest object.
protected Map getSessionMap(HttpServletRequest request)
SessionMap
. Override this method to customize how session attributes are mapped.
request
- the HttpServletRequest object.
protected void sendError(HttpServletRequest request, HttpServletResponse response, int code, Exception e)
request
- the HttpServletRequest object.response
- the HttpServletResponse object.code
- the HttpServletResponse error code (see HttpServletResponse
for possible error codes).e
- the Exception that is reported.protected HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException
MultiPartRequestWrapper
is
flexible - you should look to that first before overriding this method to handle multipart data.
request
- the HttpServletRequest object.
IOException
MultiPartRequestWrapper
protected String getSaveDir()
protected int getMaxSize()
public static Locale localeFromString(String localeStr)
Locale
from a String of the form en_US_foo into a Locale
with language "en", country "US" and variant "foo". This will parse the output of
Locale.toString()
.
todo move this to LocalizedTextUtil in xwork 1.0.6
|
WebWork Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |