Package javax.servlet.jsp

Examples of javax.servlet.jsp.PageContext


    public Set entrySet() {
        return Collections.EMPTY_SET;
    }

    public Object get(Object key) {
        PageContext pc = getPageContext();

        if (pc == null) {
            Map request = (Map) context.get("request");
            Map session = (Map) context.get("session");
            Map application = (Map) context.get("application");

            if ((request != null) && (request.get(key) != null)) {
                return request.get(key);
            } else if ((session != null) && (session.get(key) != null)) {
                return session.get(key);
            } else if ((application != null) && (application.get(key) != null)) {
                return application.get(key);
            }
        } else {
            try{
                return pc.findAttribute(key.toString());
            }catch (NullPointerException npe){
                return null;
            }
        }
View Full Code Here


    public Set keySet() {
        return Collections.EMPTY_SET;
    }

    public Object put(Object key, Object value) {
        PageContext pc = getPageContext();
        if (pc != null) {
            pc.setAttribute(key.toString(), value);
        }

        return null;
    }
View Full Code Here

    protected Map createExtraContext() {
        Map newParams = createParametersForContext();

        ActionContext ctx = new ActionContext(stack.getContext());
        ServletContext servletContext = (ServletContext) ctx.get(ServletActionContext.SERVLET_CONTEXT);
        PageContext pageContext = (PageContext) ctx.get(ServletActionContext.PAGE_CONTEXT);
        Map session = ctx.getSession();
        Map application = ctx.getApplication();

        Dispatcher du = Dispatcher.getInstance();
        Map<String, Object> extraContext = du.createContextMap(new RequestMap(req),
View Full Code Here

            LOG.debug("Trying to render template " + template + ", repeating through parents until we succeed");
        }
        UIBean tag = templateContext.getTag();
        ValueStack stack = templateContext.getStack();
        stack.push(tag);
        PageContext pageContext = (PageContext) stack.getContext().get(ServletActionContext.PAGE_CONTEXT);
        List<Template> templates = template.getPossibleTemplates(this);
        Exception exception = null;
        boolean success = false;
        for (Template t : templates) {
            try {
                Include.include(getFinalTemplateName(t), pageContext.getOut(),
                        pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse(), encoding);
                success = true;
                break;
            } catch (Exception e) {
                if (exception == null) {
                    exception = e;
View Full Code Here

        Servlet servlet = JspSupportServlet.jspSupportServlet;

        velocityManager.init(servletContext);

        boolean usedJspFactory = false;
        PageContext pageContext = (PageContext) ActionContext.getContext().get(ServletActionContext.PAGE_CONTEXT);

        if (pageContext == null && servlet != null) {
            pageContext = jspFactory.getPageContext(servlet, request, response, null, true, 8192, true);
            ActionContext.getContext().put(ServletActionContext.PAGE_CONTEXT, pageContext);
            usedJspFactory = true;
View Full Code Here

    public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Forwarding to location " + finalLocation);
        }

        PageContext pageContext = ServletActionContext.getPageContext();

        if (pageContext != null) {
            pageContext.include(finalLocation);
        } else {
            HttpServletRequest request = ServletActionContext.getRequest();
            HttpServletResponse response = ServletActionContext.getResponse();
            RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation);
View Full Code Here

              String errorPageURL,
                                      boolean needsSession, int bufferSize,
                                      boolean autoflush)
    {
        try {
      PageContext pc;
      if( usePool ) {
    pc=(PageContext)pool.get();
    if( pc == null ) pc= new PageContextImpl(this);
      } else {
    pc =  new PageContextImpl(this);
      }

      //      System.out.println("JspFactoryImpl.getPC"  + pc);
      pc.initialize(servlet, request, response, errorPageURL,
                          needsSession, bufferSize, autoflush);
     
            return pc;
        } catch (Throwable ex) {
            /* FIXME: need to do something reasonable here!! */
 
View Full Code Here

public class Task extends HttpServlet {

   public void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {

      JspFactory jspFactory = null;
      PageContext pageContext = null;
      HttpSession session = null;
      Group group = null;

      String action = null;
     
      try {
     
         // If the Group bean hasn't been added to the session alerady, add it
         // this allows the user to go directly to ANY page
         jspFactory = JspFactory.getDefaultFactory();
         pageContext = jspFactory.getPageContext(this, request, response, "/error.jsp", true, 8192, true );
         session = pageContext.getSession();
        
         group = (Group)pageContext.getAttribute("group",PageContext.SESSION_SCOPE);
         if (group == null) {
            group=(Group)Beans.instantiate(this.getClass().getClassLoader(), "addressbook.Group" );
            pageContext.setAttribute("group", group, PageContext.SESSION_SCOPE );
         }

     
         // Since case matters, we need to check for both....
         if ( request.getParameter("action") != null ) {
View Full Code Here

public class JspAutotagRuntimeTest {
    @Test
    public void testCreateRequest() {
        JspFragment jspBody = createMock(JspFragment.class);
        PageContext pageContext = createMock(PageContext.class);
        JspTag parent = createMock(JspTag.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
        expect(pageContext.getAttribute(
                ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE,
                PageContext.APPLICATION_SCOPE)).andReturn(applicationContext);
        expect(pageContext.getRequest()).andReturn(httpServletRequest);
        expect(pageContext.getResponse()).andReturn(httpServletResponse);
        replay(jspBody, pageContext, parent, applicationContext, httpServletRequest, httpServletResponse);
        JspAutotagRuntime runtime = new JspAutotagRuntime();
        runtime.setJspBody(jspBody);
        runtime.setJspContext(pageContext);
        runtime.setParent(parent);
View Full Code Here

     * @throws JspException If something goes wrong.
     */
    @Test
    public void testEvaluateWriter() throws JspException, IOException {
        JspFragment body = createMock(JspFragment.class);
        PageContext pageContext = createMock(PageContext.class);
        JspWriter writer = createMock(JspWriter.class);

        expect(pageContext.getOut()).andReturn(null);
        body.invoke(writer);

        replay(body, pageContext, writer);
        JspModelBody modelBody = new JspModelBody(body, pageContext);
        modelBody.evaluate(writer);
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.