org.apache.catalina.core
class: ApplicationRequest [javadoc |
source]
java.lang.Object
javax.servlet.ServletRequestWrapper
org.apache.catalina.core.ApplicationRequest
All Implemented Interfaces:
ServletRequest
Wrapper around a
javax.servlet.ServletRequest
that transforms an application request object (which might be the original
one passed to a servlet, or might be based on the 2.3
javax.servlet.ServletRequestWrapper class)
back into an internal
org.apache.catalina.Request.
WARNING: Due to Java's lack of support for multiple
inheritance, all of the logic in ApplicationRequest is
duplicated in ApplicationHttpRequest. Make sure that you
keep these two classes in synchronization when making changes!
- author:
Craig - R. McClanahan
- version:
$ - Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
| Field Summary |
|---|
| protected static final String[] | specials | The set of attribute names that are special for request dispatchers. |
| protected HashMap | attributes | The request attributes for this request. This is initialized from the
wrapped request, but updates are allowed. |
| protected static StringManager | sm | The string manager for this package. |
| Constructor: |
public ApplicationRequest(ServletRequest request) {
// ----------------------------------------------------------- Constructors
super(request);
setRequest(request);
}
Construct a new wrapped request around the specified servlet request. Parameters:
request - The servlet request being wrapped
|
| Methods from javax.servlet.ServletRequestWrapper: |
|---|
|
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocalName, getLocalPort, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest |
| Method from org.apache.catalina.core.ApplicationRequest Detail: |
public Object getAttribute(String name) {
// ------------------------------------------------- ServletRequest Methods
synchronized (attributes) {
return (attributes.get(name));
}
}
Override the getAttribute() method of the wrapped request. |
public Enumeration getAttributeNames() {
synchronized (attributes) {
return (new Enumerator(attributes.keySet()));
}
}
Override the getAttributeNames() method of the wrapped
request. |
protected boolean isSpecial(String name) {
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name))
return (true);
}
return (false);
}
Is this attribute name one of the special ones that is added only for
included servlets? |
public void removeAttribute(String name) {
synchronized (attributes) {
attributes.remove(name);
if (!isSpecial(name))
getRequest().removeAttribute(name);
}
}
Override the removeAttribute() method of the
wrapped request. |
public void setAttribute(String name,
Object value) {
synchronized (attributes) {
attributes.put(name, value);
if (!isSpecial(name))
getRequest().setAttribute(name, value);
}
}
Override the setAttribute() method of the
wrapped request. |
public void setRequest(ServletRequest request) {
super.setRequest(request);
// Initialize the attributes for this request
synchronized (attributes) {
attributes.clear();
Enumeration names = request.getAttributeNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
Object value = request.getAttribute(name);
attributes.put(name, value);
}
}
}
Set the request that we are wrapping. |