List of usage examples for org.apache.commons.chain.web.servlet ServletWebContext get
public Object get(Object key)
Override the default Map
behavior to return the value of a local property if the specified key matches a local property name.
From source file:org.apache.struts.chain.servlet.ExceptionHandler.java
protected ForwardConfig handle(Context context, Exception exception, ExceptionConfig exceptionConfig, ActionConfig actionConfig, ModuleConfig moduleConfig) throws Exception { // Look up the remaining properties needed for this handler ServletWebContext swcontext = (ServletWebContext) context; ActionForm actionForm = (ActionForm) swcontext.get(getActionFormKey()); HttpServletRequest request = swcontext.getRequest(); HttpServletResponse response = swcontext.getResponse(); // Handle this exception org.apache.struts.action.ExceptionHandler handler = (org.apache.struts.action.ExceptionHandler) ClassUtils .getApplicationInstance(exceptionConfig.getHandler()); return (handler.execute(exception, exceptionConfig, (ActionMapping) actionConfig, actionForm, request, response));/*from w w w .java 2 s .c o m*/ }
From source file:org.apache.struts.chain.servlet.SelectAction.java
protected String getPath(Context context) { ServletWebContext swcontext = (ServletWebContext) context; HttpServletRequest request = swcontext.getRequest(); String path = null;/*from ww w. j a va 2s. c om*/ boolean extension = false; // For prefix matching, match on the path info path = (String) request.getAttribute(Constants.INCLUDE_PATH_INFO); if (path == null) { path = request.getPathInfo(); } // For extension matching, match on the servlet path if (path == null) { path = (String) request.getAttribute(Constants.INCLUDE_SERVLET_PATH); if (path == null) { path = request.getServletPath(); } if (path == null) { throw new IllegalArgumentException("No path information in request"); } extension = true; } // Strip the module prefix and extension (if any) ModuleConfig moduleConfig = (ModuleConfig) swcontext.get(getModuleConfigKey()); String prefix = moduleConfig.getPrefix(); if (!path.startsWith(prefix)) { throw new IllegalArgumentException("Path does not start with '" + prefix + "'"); } path = path.substring(prefix.length()); if (extension) { int slash = path.lastIndexOf("/"); int period = path.lastIndexOf("."); if ((period >= 0) && (period > slash)) { path = path.substring(0, period); } } return (path); }
From source file:org.apache.struts.chain.servlet.SelectModule.java
protected String getPrefix(Context context) { // Identify the URI from which we will match a module prefix ServletWebContext swcontext = (ServletWebContext) context; HttpServletRequest request = swcontext.getRequest(); String uri = (String) request.getAttribute(Constants.INCLUDE_SERVLET_PATH); if (uri == null) { uri = request.getServletPath();/*from w w w . j a v a 2 s.c o m*/ } if (uri == null) { throw new IllegalArgumentException("No path information in request"); } // Identify the module prefix for the current module String prefix = ""; // Initialize to default prefix String prefixes[] = (String[]) swcontext.getApplicationScope().get(Globals.MODULE_PREFIXES_KEY); int lastSlash = 0; while (prefix.equals("") && ((lastSlash = uri.lastIndexOf("/")) > 0)) { uri = uri.substring(0, lastSlash); for (int i = 0; i < prefixes.length; i++) { if (uri.equals(prefixes[i])) { prefix = prefixes[i]; break; } } } return (prefix); }