org.apache.struts2.dispatcher
public class: StrutsRequestWrapper [javadoc |
source]
java.lang.Object
javax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
org.apache.struts2.dispatcher.StrutsRequestWrapper
All Implemented Interfaces:
HttpServletRequest, ServletRequest
Direct Known Subclasses:
MultiPartRequestWrapper
All Struts requests are wrapped with this class, which provides simple JSTL accessibility. This is because JSTL
works with request attributes, so this class delegates to the value stack except for a few cases where required to
prevent infinite loops. Namely, we don't let any attribute name with "#" in it delegate out to the value stack, as it
could potentially cause an infinite loop. For example, an infinite loop would take place if you called:
request.getAttribute("#attr.foo").
| Method from org.apache.struts2.dispatcher.StrutsRequestWrapper Summary: |
|---|
|
getAttribute |
| Methods from javax.servlet.http.HttpServletRequestWrapper: |
|---|
|
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestURI, getRequestURL, getRequestedSessionId, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdFromUrl, isRequestedSessionIdValid, isUserInRole |
| 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.struts2.dispatcher.StrutsRequestWrapper Detail: |
public Object getAttribute(String s) {
if (s != null && s.startsWith("javax.servlet")) {
// don't bother with the standard javax.servlet attributes, we can short-circuit this
// see WW-953 and the forums post linked in that issue for more info
return super.getAttribute(s);
}
ActionContext ctx = ActionContext.getContext();
Object attribute = super.getAttribute(s);
boolean alreadyIn = false;
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
if (b != null) {
alreadyIn = b.booleanValue();
}
// note: we don't let # come through or else a request for
// #attr.foo or #request.foo could cause an endless loop
if (!alreadyIn && attribute == null && s.indexOf("#") == -1) {
try {
// If not found, then try the ValueStack
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
ValueStack stack = ctx.getValueStack();
if (stack != null) {
attribute = stack.findValue(s);
}
} finally {
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
}
}
return attribute;
}
Gets the object, looking in the value stack if not found |