| Method from org.apache.catalina.core.ApplicationHttpRequest Detail: |
Map copyMap(Map orig) {
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);
}
Perform a shallow copy of the specified Map, and return the result. |
public Object getAttribute(String name) {
// ------------------------------------------------- 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];
}
}
}
Override the getAttribute() method of the wrapped request. |
public Enumeration getAttributeNames() {
return (new AttributeNamesEnumerator());
}
Override the getAttributeNames() method of the wrapped
request. |
public String getContextPath() {
return (this.contextPath);
}
Override the getContextPath() method of the wrapped
request. |
public String getInfo() {
return (info);
}
Return descriptive information about this implementation. |
public String getParameter(String name) {
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());
}
Override the getParameter() method of the wrapped request. |
public Map getParameterMap() {
parseParameters();
return (parameters);
}
Override the getParameterMap() method of the
wrapped request. |
public Enumeration getParameterNames() {
parseParameters();
return (new Enumerator(parameters.keySet()));
}
Override the getParameterNames() method of the
wrapped request. |
public String[] getParameterValues(String name) {
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);
}
}
Override the getParameterValues() method of the
wrapped request. |
public String getPathInfo() {
return (this.pathInfo);
}
Override the getPathInfo() method of the wrapped request. |
public String getQueryString() {
return (this.queryString);
}
Override the getQueryString() method of the wrapped
request. |
public RequestDispatcher getRequestDispatcher(String 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));
}
Return a RequestDispatcher that wraps the resource at the specified
path, which may be interpreted as relative to the current request path. |
public String getRequestURI() {
return (this.requestURI);
}
Override the getRequestURI() method of the wrapped
request. |
public StringBuffer getRequestURL() {
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);
}
Override the getRequestURL() method of the wrapped
request. |
public String getServletPath() {
return (this.servletPath);
}
Override the getServletPath() method of the wrapped
request. |
public HttpSession getSession() {
return (getSession(true));
}
Return the session associated with this Request, creating one
if necessary. |
public HttpSession getSession(boolean create) {
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);
}
}
Return the session associated with this Request, creating one
if necessary and requested. |
protected int getSpecial(String name) {
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name)) {
return (i);
}
}
return (-1);
}
|
public boolean isRequestedSessionIdValid() {
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();
}
}
Returns true if the request specifies a JSESSIONID that is valid within
the context of this ApplicationHttpRequest, false otherwise. |
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? |
protected String[] mergeValues(Object values1,
Object values2) {
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));
}
Merge the two sets of parameter values into a single String array. |
void parseParameters() {
if (parsedParams) {
return;
}
parameters = new HashMap();
parameters = copyMap(getRequest().getParameterMap());
mergeParameters();
parsedParams = true;
}
Parses the parameters of this request.
If parameters are present in both the query string and the request
content, they are merged. |
public void recycle() {
if (session != null) {
session.endAccess();
}
}
|
public void removeAttribute(String name) {
if (!removeSpecial(name))
getRequest().removeAttribute(name);
}
Override the removeAttribute() method of the
wrapped request. |
protected boolean removeSpecial(String name) {
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name)) {
specialAttributes[i] = null;
return (true);
}
}
return (false);
}
Remove a special attribute. |
public void setAttribute(String name,
Object value) {
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);
}
}
Override the setAttribute() method of the
wrapped request. |
void setContextPath(String contextPath) {
this.contextPath = contextPath;
}
Set the context path for this request. |
void setPathInfo(String pathInfo) {
this.pathInfo = pathInfo;
}
Set the path information for this request. |
void setQueryParams(String queryString) {
this.queryParamString = queryString;
}
Save query parameters for this request. |
void setQueryString(String queryString) {
this.queryString = queryString;
}
Set the query string for this request. |
void setRequest(HttpServletRequest request) {
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();
}
Set the request that we are wrapping. |
void setRequestURI(String requestURI) {
this.requestURI = requestURI;
}
Set the request URI for this request. |
void setServletPath(String servletPath) {
this.servletPath = servletPath;
}
Set the servlet path for this request. |
protected boolean setSpecial(String name,
Object value) {
for (int i = 0; i < specials.length; i++) {
if (specials[i].equals(name)) {
specialAttributes[i] = value;
return (true);
}
}
return (false);
}
|