Servlet-based implementation of the TilesApplicationContext interface.
| Method from org.apache.tiles.servlet.context.ServletTilesRequestContext Detail: |
public void dispatch(String path) throws IOException {
if (response.isCommitted() || ServletUtil.isForceInclude(request)) {
include(path);
} else {
forward(path);
}
}
|
protected void forward(String path) throws IOException {
RequestDispatcher rd = request.getRequestDispatcher(path);
if (rd == null) {
throw new IOException("No request dispatcher returned for path '"
+ path + "'");
}
try {
rd.forward(request, response);
} catch (ServletException ex) {
throw wrapServletException(ex, "ServletException including path '"
+ path + "'.");
}
}
|
public Map getHeader() {
if ((header == null) && (request != null)) {
header = new ServletHeaderMap(request);
}
return (header);
}
|
public Map getHeaderValues() {
if ((headerValues == null) && (request != null)) {
headerValues = new ServletHeaderValuesMap(request);
}
return (headerValues);
}
|
public Map getParam() {
if ((param == null) && (request != null)) {
param = new ServletParamMap(request);
}
return (param);
}
|
public Map getParamValues() {
if ((paramValues == null) && (request != null)) {
paramValues = new ServletParamValuesMap(request);
}
return (paramValues);
}
|
public HttpServletRequest getRequest() {
return request;
}
|
public Locale getRequestLocale() {
return request.getLocale();
}
|
public Map getRequestScope() {
if ((requestScope == null) && (request != null)) {
requestScope = new ServletRequestScopeMap(request);
}
return (requestScope);
}
|
public HttpServletResponse getResponse() {
return response;
}
|
public Map getSessionScope() {
if ((sessionScope == null) && (request != null)) {
sessionScope = new ServletSessionScopeMap(request);
}
return (sessionScope);
}
|
public void include(String path) throws IOException {
ServletUtil.setForceInclude(request, true);
RequestDispatcher rd = request.getRequestDispatcher(path);
if (rd == null) {
throw new IOException("No request dispatcher returned for path '"
+ path + "'");
}
try {
rd.include(request, response);
} catch (ServletException ex) {
throw wrapServletException(ex, "ServletException including path '"
+ path + "'.");
}
}
|
public void initialize(HttpServletRequest request,
HttpServletResponse response) {
// Save the specified Servlet API object references
this.request = request;
this.response = response;
// Perform other setup as needed
}
|
public boolean isUserInRole(String role) {
return request.isUserInRole(role);
}
|
public void release() {
// Release references to allocated collections
header = null;
headerValues = null;
param = null;
paramValues = null;
requestScope = null;
sessionScope = null;
// Release references to Servlet API objects
request = null;
response = null;
super.release();
}
Release references to allocated resources acquired in
initialize() of via subsequent processing. After this
method is called, subsequent calls to any other method than
initialize() will return undefined results.
|
protected IOException wrapServletException(ServletException ex,
String message) {
IOException retValue;
Throwable rootCause = ex.getRootCause();
if (rootCause != null) {
// Replace the ServletException with an IOException, with the root
// cause of the first as the cause of the latter.
retValue = new TilesIOException(message, rootCause);
} else {
retValue = new TilesIOException(message, ex);
}
return retValue;
}
Wraps a ServletException to create an IOException with the root cause if present. |