Fields Summary |
---|
protected static final String[] | specialsThe set of attribute names that are special for request dispatchers. |
protected static org.apache.catalina.util.StringManager | smThe string manager for this package. |
protected org.apache.catalina.Context | contextThe context for this request. |
protected String | contextPathThe context path for this request. |
protected boolean | crossContextIf this request is cross context, since this changes session accesss
behavior. |
protected Object | dispatcherTypeThe current dispatcher type. |
protected static final String | infoDescriptive information about this implementation. |
protected Map | parametersThe request parameters for this request. This is initialized from the
wrapped request, but updates are allowed. |
private boolean | parsedParamsHave the parameters for this request already been parsed? |
protected String | pathInfoThe path information for this request. |
private String | queryParamStringThe query parameters for the current request. |
protected String | queryStringThe query string for this request. |
protected Object | requestDispatcherPathThe current request dispatcher path. |
protected String | requestURIThe request URI for this request. |
protected String | servletPathThe servlet path for this request. |
protected org.apache.catalina.Session | sessionThe currently active session for this request. |
protected Object[] | specialAttributesSpecial attributes. |
Methods Summary |
---|
java.util.Map | copyMap(java.util.Map orig)Perform a shallow copy of the specified Map, and return the result.
if (orig == null)
return (new HashMap());
HashMap dest = new HashMap();
Iterator keys = orig.keySet().iterator();
while (keys.hasNext()) {
String key = (String) keys.next();
dest.put(key, orig.get(key));
}
return (dest);
|
public java.lang.Object | getAttribute(java.lang.String name)Override the getAttribute() method of the wrapped request.
// ------------------------------------------------- ServletRequest Methods
if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
return dispatcherType;
} else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
if ( requestDispatcherPath != null ){
return requestDispatcherPath.toString();
} else {
return null;
}
}
int pos = getSpecial(name);
if (pos == -1) {
return getRequest().getAttribute(name);
} else {
if ((specialAttributes[pos] == null)
&& (specialAttributes[5] == null) && (pos >= 5)) {
// If it's a forward special attribute, and null, it means this
// is an include, so we check the wrapped request since
// the request could have been forwarded before the include
return getRequest().getAttribute(name);
} else {
return specialAttributes[pos];
}
}
|
public java.util.Enumeration | getAttributeNames()Override the getAttributeNames() method of the wrapped
request.
return (new AttributeNamesEnumerator());
|
public java.lang.String | getContextPath()Override the getContextPath() method of the wrapped
request.
return (this.contextPath);
|
public java.lang.String | getInfo()Return descriptive information about this implementation.
return (info);
|
public java.lang.String | getParameter(java.lang.String name)Override the getParameter() method of the wrapped request.
parseParameters();
Object value = parameters.get(name);
if (value == null)
return (null);
else if (value instanceof String[])
return (((String[]) value)[0]);
else if (value instanceof String)
return ((String) value);
else
return (value.toString());
|
public java.util.Map | getParameterMap()Override the getParameterMap() method of the
wrapped request.
parseParameters();
return (parameters);
|
public java.util.Enumeration | getParameterNames()Override the getParameterNames() method of the
wrapped request.
parseParameters();
return (new Enumerator(parameters.keySet()));
|
public java.lang.String[] | getParameterValues(java.lang.String name)Override the getParameterValues() method of the
wrapped request.
parseParameters();
Object value = parameters.get(name);
if (value == null)
return ((String[]) null);
else if (value instanceof String[])
return ((String[]) value);
else if (value instanceof String) {
String values[] = new String[1];
values[0] = (String) value;
return (values);
} else {
String values[] = new String[1];
values[0] = value.toString();
return (values);
}
|
public java.lang.String | getPathInfo()Override the getPathInfo() method of the wrapped request.
return (this.pathInfo);
|
public java.lang.String | getQueryString()Override the getQueryString() method of the wrapped
request.
return (this.queryString);
|
public javax.servlet.RequestDispatcher | getRequestDispatcher(java.lang.String path)Return a RequestDispatcher that wraps the resource at the specified
path, which may be interpreted as relative to the current request path.
if (context == null)
return (null);
// If the path is already context-relative, just pass it through
if (path == null)
return (null);
else if (path.startsWith("/"))
return (context.getServletContext().getRequestDispatcher(path));
// Convert a request-relative path to a context-relative one
String servletPath =
(String) getAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR);
if (servletPath == null)
servletPath = getServletPath();
// Add the path info, if there is any
String pathInfo = getPathInfo();
String requestPath = null;
if (pathInfo == null) {
requestPath = servletPath;
} else {
requestPath = servletPath + pathInfo;
}
int pos = requestPath.lastIndexOf('/");
String relative = null;
if (pos >= 0) {
relative = RequestUtil.normalize
(requestPath.substring(0, pos + 1) + path);
} else {
relative = RequestUtil.normalize(requestPath + path);
}
return (context.getServletContext().getRequestDispatcher(relative));
|
public java.lang.String | getRequestURI()Override the getRequestURI() method of the wrapped
request.
return (this.requestURI);
|
public java.lang.StringBuffer | getRequestURL()Override the getRequestURL() method of the wrapped
request.
StringBuffer url = new StringBuffer();
String scheme = getScheme();
int port = getServerPort();
if (port < 0)
port = 80; // Work around java.net.URL bug
url.append(scheme);
url.append("://");
url.append(getServerName());
if ((scheme.equals("http") && (port != 80))
|| (scheme.equals("https") && (port != 443))) {
url.append(':");
url.append(port);
}
url.append(getRequestURI());
return (url);
|
public java.lang.String | getServletPath()Override the getServletPath() method of the wrapped
request.
return (this.servletPath);
|
public javax.servlet.http.HttpSession | getSession()Return the session associated with this Request, creating one
if necessary.
return (getSession(true));
|
public javax.servlet.http.HttpSession | getSession(boolean create)Return the session associated with this Request, creating one
if necessary and requested.
if (crossContext) {
// There cannot be a session if no context has been assigned yet
if (context == null)
return (null);
// Return the current session if it exists and is valid
if (session != null && session.isValid()) {
return (session.getSession());
}
HttpSession other = super.getSession(false);
if (create && (other == null)) {
// First create a session in the first context: the problem is
// that the top level request is the only one which can
// create the cookie safely
other = super.getSession(true);
}
if (other != null) {
Session localSession = null;
try {
localSession =
context.getManager().findSession(other.getId());
} catch (IOException e) {
// Ignore
}
if (localSession == null && create) {
localSession =
context.getManager().createSession(other.getId());
}
if (localSession != null) {
localSession.access();
session = localSession;
return session.getSession();
}
}
return null;
} else {
return super.getSession(create);
}
|
protected int | getSpecial(java.lang.String name)Get a special attribute.
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name)) {
return (i);
}
}
return (-1);
|
public boolean | isRequestedSessionIdValid()Returns true if the request specifies a JSESSIONID that is valid within
the context of this ApplicationHttpRequest, false otherwise.
if (crossContext) {
String requestedSessionId = getRequestedSessionId();
if (requestedSessionId == null)
return (false);
if (context == null)
return (false);
Manager manager = context.getManager();
if (manager == null)
return (false);
Session session = null;
try {
session = manager.findSession(requestedSessionId);
} catch (IOException e) {
session = null;
}
if ((session != null) && session.isValid()) {
return (true);
} else {
return (false);
}
} else {
return super.isRequestedSessionIdValid();
}
|
protected boolean | isSpecial(java.lang.String name)Is this attribute name one of the special ones that is added only for
included servlets?
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name))
return (true);
}
return (false);
|
private void | mergeParameters()Merge the parameters from the saved query parameter string (if any), and
the parameters already present on this request (if any), such that the
parameter values from the query string show up first if there are
duplicate parameter names.
if ((queryParamString == null) || (queryParamString.length() < 1))
return;
HashMap queryParameters = new HashMap();
String encoding = getCharacterEncoding();
if (encoding == null)
encoding = "ISO-8859-1";
try {
RequestUtil.parseParameters
(queryParameters, queryParamString, encoding);
} catch (Exception e) {
;
}
Iterator keys = parameters.keySet().iterator();
while (keys.hasNext()) {
String key = (String) keys.next();
Object value = queryParameters.get(key);
if (value == null) {
queryParameters.put(key, parameters.get(key));
continue;
}
queryParameters.put
(key, mergeValues(value, parameters.get(key)));
}
parameters = queryParameters;
|
protected java.lang.String[] | mergeValues(java.lang.Object values1, java.lang.Object values2)Merge the two sets of parameter values into a single String array.
ArrayList results = new ArrayList();
if (values1 == null)
;
else if (values1 instanceof String)
results.add(values1);
else if (values1 instanceof String[]) {
String values[] = (String[]) values1;
for (int i = 0; i < values.length; i++)
results.add(values[i]);
} else
results.add(values1.toString());
if (values2 == null)
;
else if (values2 instanceof String)
results.add(values2);
else if (values2 instanceof String[]) {
String values[] = (String[]) values2;
for (int i = 0; i < values.length; i++)
results.add(values[i]);
} else
results.add(values2.toString());
String values[] = new String[results.size()];
return ((String[]) results.toArray(values));
|
void | parseParameters()Parses the parameters of this request.
If parameters are present in both the query string and the request
content, they are merged.
if (parsedParams) {
return;
}
parameters = new HashMap();
parameters = copyMap(getRequest().getParameterMap());
mergeParameters();
parsedParams = true;
|
public void | recycle()Recycle this request
if (session != null) {
session.endAccess();
}
|
public void | removeAttribute(java.lang.String name)Override the removeAttribute() method of the
wrapped request.
if (!removeSpecial(name))
getRequest().removeAttribute(name);
|
protected boolean | removeSpecial(java.lang.String name)Remove a special attribute.
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name)) {
specialAttributes[i] = null;
return (true);
}
}
return (false);
|
public void | setAttribute(java.lang.String name, java.lang.Object value)Override the setAttribute() method of the
wrapped request.
if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
dispatcherType = value;
return;
} else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
requestDispatcherPath = value;
return;
}
if (!setSpecial(name, value)) {
getRequest().setAttribute(name, value);
}
|
void | setContextPath(java.lang.String contextPath)Set the context path for this request.
this.contextPath = contextPath;
|
void | setPathInfo(java.lang.String pathInfo)Set the path information for this request.
this.pathInfo = pathInfo;
|
void | setQueryParams(java.lang.String queryString)Save query parameters for this request.
this.queryParamString = queryString;
|
void | setQueryString(java.lang.String queryString)Set the query string for this request.
this.queryString = queryString;
|
void | setRequest(javax.servlet.http.HttpServletRequest request)Set the request that we are wrapping.
super.setRequest(request);
// Initialize the attributes for this request
dispatcherType = request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
requestDispatcherPath =
request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);
// Initialize the path elements for this request
contextPath = request.getContextPath();
pathInfo = request.getPathInfo();
queryString = request.getQueryString();
requestURI = request.getRequestURI();
servletPath = request.getServletPath();
|
void | setRequestURI(java.lang.String requestURI)Set the request URI for this request.
this.requestURI = requestURI;
|
void | setServletPath(java.lang.String servletPath)Set the servlet path for this request.
this.servletPath = servletPath;
|
protected boolean | setSpecial(java.lang.String name, java.lang.Object value)Set a special attribute.
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name)) {
specialAttributes[i] = value;
return (true);
}
}
return (false);
|