public ServletContext getServletContext() { if (servletContext != null) return servletContext; else return ServletActionContext.getServletContext(); }
/** * 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()); }
/** * 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()); }
/** * 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; } }
/** * This method is called from {@link #doExecute(String, ActionInvocation)} * to obtain the FreeMarker configuration object that this result will use * for template loading. This is a hook that allows you to custom-configure * the configuration object in a subclass, or to fetch it from an IoC * container. <p/><b>The default implementation obtains the configuration * from the ConfigurationManager instance. </b> */ protected Configuration getConfiguration() throws TemplateException { return FreemarkerManager.getInstance().getConfiguration( ServletActionContext.getServletContext()); }
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; }
/** * This method is called from {@link #doExecute(String, ActionInvocation)} to obtain the * FreeMarker configuration object that this result will use for template loading. This is a * hook that allows you to custom-configure the configuration object in a subclass, or to fetch * it from an IoC container. * <p/> * <b> * The default implementation obtains the configuration from the ConfigurationManager instance. * </b> */ protected Configuration getConfiguration() throws TemplateException { return FreemarkerManager.getInstance().getConfiguration(ServletActionContext.getServletContext()); }
ctx = ServletActionContext.getServletContext(); } catch (NullPointerException npe) {
ServletContext servletContext = ServletActionContext.getServletContext();
/** * 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); }
HttpServletResponse response = ServletActionContext.getResponse(); JspFactory jspFactory = null; ServletContext servletContext = ServletActionContext.getServletContext(); Servlet servlet = JspSupportServlet.jspSupportServlet;
/** * 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); }
JspFactory jspFactory = null; ServletContext servletContext = ServletActionContext .getServletContext(); Servlet servlet = JspSupportServlet.jspSupportServlet;