Package javax.servlet

Examples of javax.servlet.RequestDispatcher


        if (path == null || (!path.startsWith("/") && !"".equals(path)))
        {
            return null;
        }

        RequestDispatcher dispatcher = this.provider.getRequestDispatcher(path);
        return dispatcher != null ? dispatcher : super.getRequestDispatcher(path);
    }
View Full Code Here


     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        try {
            request.setAttribute("type", tax.getRate());
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/result.jsp");
            dispatcher.forward(request, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

            errorMessage.append("Error========>" + t.getMessage());
            request.setAttribute("infoMessage", "");
            e.printStackTrace();
        } finally {
            request.setAttribute("errorMessage", errorMessage.toString());
            RequestDispatcher resultView = request.getRequestDispatcher("index.jsp");
            resultView.forward(request, response);
        }
    }
View Full Code Here

        }
        /*
         * Fetch dispatcher for '/'. This will make 'rd' initialized to dispatcher handling for application root.
         */
        RequestDispatcher rd = getServletContext().getRequestDispatcher("/");

        if (rd != null) {
            /*
             * Forward the request to default servlet handling calls to application root. In our case FacesServlet
             */
            rd.forward(req, resp);
            return;
        } else {
            // this is bad thing, lets throw exception to make user aware of that?
            throw new IllegalStateException("Container is not well!");
        }
View Full Code Here

   */
  public static void setErrorAndForward(String errMsg,
      HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setAttribute("error.msg", errMsg);
    RequestDispatcher dispatcher = request.getRequestDispatcher(
        "/job_authorization_error.jsp");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    dispatcher.forward(request, response);
  }
View Full Code Here

            System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));

            // Perform cross context dispatch to another context
            // Over there we will check that the session attribute added above is not visible
            ServletContext contextB = getServletContext().getContext("/contextB");
            RequestDispatcher dispatcherB = contextB.getRequestDispatcher(request.getServletPath());
            dispatcherB.forward(request, response);

            // Check that we don't see things put in session by contextB
            Object objectB = session.getAttribute("B");
            assert objectB == null;
            System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
View Full Code Here

                            response.sendRedirect(URIUtil.addPaths( _context.getContextPath(),ipath));
                    }
                    else
                    {
                        // Forward to the index
                        RequestDispatcher dispatcher=request.getRequestDispatcher(ipath);
                        if (dispatcher!=null)
                        {
                            if (included.booleanValue())
                                dispatcher.include(request,response);
                            else
                            {
                                request.setAttribute("org.mortbay.jetty.welcome",ipath);
                                dispatcher.forward(request,response);
                            }
                        }
                    }
                }
                else
View Full Code Here

import org.ice.http.HttpResponse;

public class JstlView extends TemplateView {

  public void render(HttpRequest request, HttpResponse response) {
    RequestDispatcher rd = request.getRequestDispatcher(template);
    if (rd == null) {
      response.appendBody("Template not found: "+template);
      return;
    }
    try {
      rd.include(request, response);
    } catch (Exception ex) {
//      Logger.getLogger().log("Error while processing template: "+ex.toString(), Logger.LEVEL_WARNING);
      response.appendBody("Failed to read template: "+ex.toString());
    }
  }
View Full Code Here

        try {
            ServletContextAndPath csAndP = getServletContextAndPath(
                    originalPath, virtual);
            ServletContext context = csAndP.getServletContext();
            String path = csAndP.getPath();
            RequestDispatcher rd = context.getRequestDispatcher(path);
            if (rd == null) {
                throw new IOException(
                        "Couldn't get request dispatcher for path: " + path);
            }
            ByteArrayServletOutputStream basos =
                new ByteArrayServletOutputStream();
            ResponseIncludeWrapper responseIncludeWrapper =
                new ResponseIncludeWrapper(context, req, res, basos);
            rd.include(req, responseIncludeWrapper);
            //We can't assume the included servlet flushed its output
            responseIncludeWrapper.flushOutputStreamOrWriter();
            byte[] bytes = basos.toByteArray();

            //Assume platform default encoding unless otherwise specified
View Full Code Here

                        // make sure to set hidden accessingURL again
                       
                        // set response header to alert ajax calls of a login error.
                        httpResponse.addHeader("LogginError", WebappUtil.getMessage("login_error"));
                       
                        RequestDispatcher requestDispatcher=httpRequest.getRequestDispatcher("/login.jsp?accessingURL=" +
                                httpResponse.encodeURL(accessingURL) + "&loginError=" +
                                httpResponse.encodeURL(WebappUtil.getMessage("login_error")));
                        requestDispatcher.forward(httpRequest, httpResponse);
                        return;
                    }
                }
               
            } else if(!securityHandler.isPersonLoggedIn(httpRequest)) {
                // the person isn't logged in, see if they are accessing a protected resource

                // since we have a rest type of url, need to get path info to decide if path protected
                String pathInfo=httpRequest.getPathInfo();
                if(pathInfo != null) {
                    resource += pathInfo;
                    // using the rest type urls go only 3 '/' deep for security check (e.g. /xxx/xxxx/xxx)
                    resource=getSecurityURI(resource);
                    logger.finer("\nEntity Filter - checking if protect path = " + resource);
                }
               
               
                logger.finer("Checking resource to see if login required " + resource);
                logger.finer("Entity Filter - Checking resource to see if login required - " + resource);
                //resource=resource.substring(resource.lastIndexOf("/") + 1);
                // if null page then using default welcome mechanism, assume it is an accessable page.
                if(resource != null) {
                    if(securePages.contains(resource)) {
                        logger.finer("Entity Filter - have secure resource - " + resource);
                       
                        // set response header to alert ajax calls of a login error.
                        httpResponse.addHeader("NeedLogin", "The user needs to be logged in");
                       
                        // need to login to get to these page
                        //??? todo, need pathinfo and querystring
                        // what about post payload if an event is being submitted for creation
                        RequestDispatcher requestDispatcher=httpRequest.getRequestDispatcher("/login.jsp?accessingURL=" +
                                httpResponse.encodeURL(getAccessURL(httpRequest)));
                        requestDispatcher.forward(httpRequest, httpResponse);
                        return;
                    }
                }
            }
           
View Full Code Here

TOP

Related Classes of javax.servlet.RequestDispatcher

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.