@Override protected HttpServletRequest getHttpServletRequest() { return ServletActionContext.getRequest(); } }
/** * Executes the regular servlet result. * * @param finalLocation * @param actionInvocation */ private void executeRegularServletResult(String finalLocation, ActionInvocation actionInvocation) throws ServletException, IOException { ServletContext ctx = ServletActionContext.getServletContext(); HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse(); try { ctx.getRequestDispatcher(finalLocation).include(req, res); } catch (ServletException e) { LOG.error("ServletException including " + finalLocation, e); throw e; } catch (IOException e) { LOG.error("IOException while including result '" + finalLocation + "'", e); throw e; } }
/** * Build the instance of the ScopesHashModel, including JspTagLib support * <p/>Objects added to the model are <p/> * <ul> * <li>Application - servlet context attributes hash model * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model * <li>req - the HttpServletRequst object for direct access * <li>res - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself * <li>exception - optional : the JSP or Servlet exception as per the * servlet spec (for JSP Exception pages) * <li>webwork - instance of the WebWorkUtil class * </ul> */ protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext .getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); OgnlValueStack stack = ServletActionContext.getContext() .getValueStack(); return FreemarkerManager.getInstance().buildTemplateModel(stack, invocation.getAction(), servletContext, request, response, wrapper); }
private boolean authenticateWithSeraphAuthenticator(String userName, String password) throws AuthenticatorException { SecurityConfig securityConfig = SeraphUtils.getConfig(ServletActionContext.getRequest()); if (null != securityConfig) { Authenticator authenticator = securityConfig.getAuthenticator(); boolean authenticated = authenticator.login( ServletActionContext.getRequest(), ServletActionContext.getResponse(), userName, password ); log.debug(new StringBuilder("Authenticating as ") .append(userName) .append(" with md5hex password ").append(DigestUtils.md5Hex(StringUtils.defaultString(password))) .append(" by ").append(authenticator.getClass().getName()) .append(" results in ").append(authenticated).toString()); return authenticated; } log.error("Unable to get an Authenticator from Seraph."); return false; }
protected Templates getTemplates(String path) throws TransformerException, IOException { String pathFromRequest = ServletActionContext.getRequest().getParameter("xslt.location"); if (pathFromRequest != null) path = pathFromRequest; if (path == null) throw new TransformerException("Stylesheet path is null"); Templates templates = (Templates) templatesCache.get(path); if (noCache || (templates == null)) { synchronized (templatesCache) { URL resource = ServletActionContext.getServletContext().getResource(path); if (resource == null) { throw new TransformerException("Stylesheet " + path + " not found in resources."); } log.debug("Preparing XSLT stylesheet templates: " + path); TransformerFactory factory = TransformerFactory.newInstance(); templates = factory.newTemplates(new StreamSource(resource.openStream())); templatesCache.put(path, templates); } } return templates; }
@Override protected HttpServletResponse getHttpServletResponse() { return ServletActionContext.getResponse(); }
PageContext pageContext = ServletActionContext.getPageContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation);
Map session = ServletActionContext.getContext().getSession(); HttpServletRequest request = ServletActionContext.getRequest(); expirationDate.setTime( user.getLastPasswordChange() ); expirationDate.add( Calendar.DAY_OF_MONTH, policy.getPasswordExpirationDays() ); Map session = ServletActionContext.getContext().getSession(); session.put( "passwordExpirationNotification", expirationDate.getTime().toString() );
public ServletContext getServletContext() { if (servletContext != null) return servletContext; else return ServletActionContext.getServletContext(); }
private static String translateVariable(String input) { OgnlValueStack valueStack = ServletActionContext.getContext().getValueStack(); String output = TextParseUtil.translateVariables(input, valueStack); return output; }
/** * Applies the decorator, creating the relevent contexts and delegating to * the extended applyDecorator(). * * @param page The page * @param decorator The decorator * @param req The servlet request * @param res The servlet response */ protected void applyDecorator(Page page, Decorator decorator, HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ServletContext servletContext = filterConfig.getServletContext(); ActionContext ctx = ServletActionContext.getActionContext(req); if (ctx == null) { // ok, one isn't associated with the request, so let's get a ThreadLocal one (which will create one if needed) OgnlValueStack vs = new OgnlValueStack(); vs.getContext().putAll(DispatcherUtils.getInstance().createContextMap(req, res, null, servletContext)); ctx = new ActionContext(vs.getContext()); if (ctx.getActionInvocation() == null) { // put in a dummy ActionSupport so basic functionality still works ActionSupport action = new ActionSupport(); vs.push(action); ctx.setActionInvocation(new DummyActionInvocation(action)); } } // delegate to the actual page decorator applyDecorator(page, decorator, req, res, servletContext, ctx); }
/** * The default writer writes directly to the response writer. */ protected Writer getWriter() throws IOException { return ServletActionContext.getResponse().getWriter(); }
this.wrapper = getObjectWrapper(); HttpServletRequest req = ServletActionContext.getRequest(); HttpServletResponse res = ServletActionContext.getResponse();
/** * Get the URI Resolver to be called by the processor when it encounters an xsl:include, xsl:import, or document() * function. The default is an instance of ServletURIResolver, which operates relative to the servlet context. */ protected URIResolver getURIResolver() { return new ServletURIResolver( ServletActionContext.getServletContext()); }
protected TemplateModel createModel(ObjectWrapper wrapper, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws TemplateModelException { OgnlValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if (ServletActionContext.getContext().getActionInvocation() != null) { action = ServletActionContext.getContext().getActionInvocation().getAction(); } TemplateModel model = FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper); return model; }
public String execute() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); String requestedUrl = request.getPathInfo(); if (successResultValue == null) successResultValue = requestedUrl; return SUCCESS; }
this.invocation = invocation; HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); ServletContext servletContext = ServletActionContext.getServletContext();
/** * Prints the current context to the response in XML format. */ protected void printContext() { HttpServletResponse res = ServletActionContext.getResponse(); res.setContentType("text/xml"); try { PrettyPrintWriter writer = new PrettyPrintWriter( ServletActionContext.getResponse().getWriter()); printContext(writer); writer.close(); } catch (IOException ex) { ex.printStackTrace(); } }
/** * Build the instance of the ScopesHashModel, including JspTagLib support * <p/> * Objects added to the model are * <p/> * <ul> * <li>Application - servlet context attributes hash model * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model * <li>req - the HttpServletRequst object for direct access * <li>res - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself * <li>exception - optional : the JSP or Servlet exception as per the servlet spec (for JSP Exception pages) * <li>webwork - instance of the WebWorkUtil class * </ul> */ protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); OgnlValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException return FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper); }
/** * Execute the given Tiles controller. * * @param controller the component controller to execute * @param context the component context * @param request current HTTP request * @param response current HTTP response * @throws Exception if controller execution failed */ protected void executeController( Controller controller, ComponentContext context, HttpServletRequest request, HttpServletResponse response) throws Exception { controller.execute(context, request, response, ServletActionContext.getServletContext()); }