Package javax.servlet.jsp

Examples of javax.servlet.jsp.PageContext


    }

    protected void doRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // save the old PageContext
        PageContext oldPageContext = ServletActionContext.getPageContext();

        // create a new PageContext
        JspFactory jspFactory = JspFactory.getDefaultFactory();

        PageContext pageContext = jspFactory.getPageContext(this, request, response, null, true, 8192, true);

        // put the new PageContext into ActionContext
        ActionContext actionContext = ActionContext.getContext();

        actionContext.put(ServletActionContext.PAGE_CONTEXT, pageContext);

        /*
         * Must put the stack into HttpServletRequest, because the WebWork JSP
         * Taglib will use it to judge whether there are some errors in stack.
         */
        OgnlValueStack stack = ActionContext.getContext().getValueStack();

        //request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,
        // stack);
        //Moved to WebWorkPortlet doService()

        VelocityManager velocityManager = VelocityManager.getInstance();
        Context resultContext = velocityManager.createContext(stack, request, response);

        response.setContentType("text/html");

        try {
            String location = (String) ActionContext.getContext().get("template");
            Template template = velocityManager.getVelocityEngine().getTemplate(location);

            Writer writer = pageContext.getOut();
            template.merge(resultContext, writer);
            writer.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
View Full Code Here


    JspFactory factory = JspFactory.getDefaultFactory();
    String errorPageURL = null;
    int bufferSize = (JspWriter.DEFAULT_BUFFER <= 0) ? 1024 : JspWriter.DEFAULT_BUFFER;
    boolean needsSession = false;
    boolean autoFlush = true;
    PageContext pageContext = null;
    try {
      req.setCharacterEncoding("UTF-8");
      pageContext = factory.getPageContext(this, req, resp,
        errorPageURL, needsSession, bufferSize, autoFlush);
   
      // Create a shared wrapper
      PageRequest request = new JspPageRequest(pageContext);
      PageResponse response = new JspPageResponse(pageContext);

      // Extract the file name
      String encoding = "utf-8"; // We use utf-8 in our JSPs
      String fileUrl = SearchToolkit.extractFileUrl(req.getRequestURI(), encoding);

      // Check the file
      try {
        if (SearchToolkit.allowFileAccess(request, fileUrl)) {
          // Access allowed -> Send the file
          SearchToolkit.sendFile(request, response, RegainToolkit.urlToFile(fileUrl));
        } else {
          // Access not allowed -> Send 403 Forbidden
          resp.sendError(403);
        }
      }
      catch (RegainException exc) {
        throw new ServletException("Checking file access failed: " + fileUrl, exc);
      }
    }
    catch (Exception exc) {
      pageContext.handlePageException(exc);
    } finally {
      factory.releasePageContext(pageContext);
    }
  }
View Full Code Here

     * Returns a variable resolver that will resolve variables by searching through
     * the page scope, request scope, session scope and application scope for an
     * attribute with a matching name.
     */
    public VariableResolver getVariableResolver() {
        final PageContext ctx = this;

        return new VariableResolver() {
            public Object resolveVariable(String name) throws ELException {
                return ctx.findAttribute(name);
            }
        };
    }
View Full Code Here

     * Returns a variable resolver that will resolve variables by searching through
     * the page scope, request scope, session scope and application scope for an
     * attribute with a matching name.
     */
    public VariableResolver getVariableResolver() {
        final PageContext ctx = this;

        return new VariableResolver() {
            public Object resolveVariable(String name) throws ELException {
                return ctx.findAttribute(name);
            }
        };
    }
View Full Code Here

    /**
     * Creates the Map that "wraps" page-scoped attributes
     */
    public static Map createPageScopeMap(PageContext pContext)
    {
        final PageContext context = pContext;

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return context.getAttributeNamesInScope
                        (PageContext.PAGE_SCOPE);
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return context.getAttribute
                            ((String) pKey,
                                    PageContext.PAGE_SCOPE);
                } else {
                    return null;
                }
View Full Code Here

    /**
     * Creates the Map that "wraps" request-scoped attributes
     */
    public static Map createRequestScopeMap(PageContext pContext)
    {
        final PageContext context = pContext;

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return context.getAttributeNamesInScope
                        (PageContext.REQUEST_SCOPE);
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return context.getAttribute
                            ((String) pKey,
                                    PageContext.REQUEST_SCOPE);
                } else {
                    return null;
                }
View Full Code Here

    /**
     * Creates the Map that "wraps" session-scoped attributes
     */
    public static Map createSessionScopeMap(PageContext pContext)
    {
        final PageContext context = pContext;

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return context.getAttributeNamesInScope
                        (PageContext.SESSION_SCOPE);
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return context.getAttribute
                            ((String) pKey,
                                    PageContext.SESSION_SCOPE);
                } else {
                    return null;
                }
View Full Code Here

    /**
     * Creates the Map that "wraps" application-scoped attributes
     */
    public static Map createApplicationScopeMap(PageContext pContext)
    {
        final PageContext context = pContext;

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return context.getAttributeNamesInScope
                        (PageContext.APPLICATION_SCOPE);
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return context.getAttribute
                            ((String) pKey,
                                    PageContext.APPLICATION_SCOPE);
                } else {
                    return null;
                }
View Full Code Here

     * Returns null if the variable is not found.
     */
    public Object resolveVariable(String pName,
                                  Object pContext)
            throws ELException {
        PageContext ctx = (PageContext) pContext;

        // Check for implicit objects
        if ("pageContext".equals(pName)) {
            return ctx;
        } else if ("pageScope".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getPageScopeMap();
        } else if ("requestScope".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getRequestScopeMap();
        } else if ("sessionScope".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getSessionScopeMap();
        } else if ("applicationScope".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getApplicationScopeMap();
        } else if ("param".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getParamMap();
        } else if ("paramValues".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getParamsMap();
        } else if ("header".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getHeaderMap();
        } else if ("headerValues".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getHeadersMap();
        } else if ("initParam".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getInitParamMap();
        } else if ("cookie".equals(pName)) {
            return ImplicitObjects.
                    getImplicitObjects(ctx).
                    getCookieMap();
        }

        // Otherwise, just look it up in the page context
        else {
            return ctx.findAttribute(pName);
        }
    }
View Full Code Here

  // Logger
  private static Logger logger = LoggerFactory.getLogger(JstlMessageResolver.class);

  public String getResource(String messageKey, String defaultValue, Object... params) {

    PageContext pageContext = (PageContext) params[0];
    String message = null;
    ResourceBundle bundle = null;

    LocalizationContext localizationContext = BundleSupport.getLocalizationContext(pageContext);
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.PageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.