Java Code Examples for javax.servlet.http.HttpServletRequest#getRequestDispatcher()

The following examples show how to use javax.servlet.http.HttpServletRequest#getRequestDispatcher() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TiposAtividadesControle.java    From redesocial with MIT License 6 votes vote down vote up
private void editar(HttpServletRequest request, HttpServletResponse response) throws Exception{
    try {
        Integer id = Integer.parseInt(request.getParameter("id"));

        TiposAtividadesBO tiposAtividadesBO = new TiposAtividadesBO();
        TiposAtividades tiposAtividades = tiposAtividadesBO.selecionar(id);

        request.setAttribute("atividade", tiposAtividades);

        request.setAttribute("mensagem", "Registro selecionado com sucesso");
    } catch (Exception ex){
        request.setAttribute("erro", ex.getMessage());
    }

    RequestDispatcher rd = request.getRequestDispatcher("paginas/tiposAtividades.jsp");
    rd.forward(request, response);
}
 
Example 2
Source File: ShibcasAuthServlet.java    From shib-cas-authn3 with Apache License 2.0 5 votes vote down vote up
private void loadErrorPage(final HttpServletRequest request, final HttpServletResponse response) {
    final RequestDispatcher requestDispatcher = request.getRequestDispatcher("/no-conversation-state.jsp");
    try {
        requestDispatcher.forward(request, response);
    } catch (final Exception e) {
        logger.error("Error rendering the empty conversation state (shib-cas-authn3) error view.");
        response.resetBuffer();
        response.setStatus(404);
    }
}
 
Example 3
Source File: BenchmarkTest00063.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00063", "FileName");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00063.html");
	rd.include(request, response);
}
 
Example 4
Source File: BenchmarkTest00967.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00967", "someSecret");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/hash-01/BenchmarkTest00967.html");
	rd.include(request, response);
}
 
Example 5
Source File: BenchmarkTest01837.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest01837", "FileName");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/pathtraver-02/BenchmarkTest01837.html");
	rd.include(request, response);
}
 
Example 6
Source File: BenchmarkTest00076.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00076", "someSecret");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/hash-00/BenchmarkTest00076.html");
	rd.include(request, response);
}
 
Example 7
Source File: BenchmarkTest01876.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest01876", "my_userid");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/trustbound-01/BenchmarkTest01876.html");
	rd.include(request, response);
}
 
Example 8
Source File: ToDoServlet.java    From gradle-in-action-source with MIT License 5 votes vote down vote up
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String servletPath = request.getServletPath();
    String view = processRequest(servletPath, request);
    RequestDispatcher dispatcher = request.getRequestDispatcher(view);
    dispatcher.forward(request, response);
}
 
Example 9
Source File: BenchmarkTest01874.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest01874", "color");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/trustbound-01/BenchmarkTest01874.html");
	rd.include(request, response);
}
 
Example 10
Source File: BillingAdapterServlet.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * Forward request to index page
 */
protected void forward(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {

    RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
    rd.forward(request, response);
}
 
Example 11
Source File: ToDoServlet.java    From gradle-in-action-source with MIT License 5 votes vote down vote up
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String servletPath = request.getServletPath();
    String view = processRequest(servletPath, request);
    RequestDispatcher dispatcher = request.getRequestDispatcher(view);
    dispatcher.forward(request, response);
}
 
Example 12
Source File: BenchmarkTest01866.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest01866", "whatever");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/weakrand-04/BenchmarkTest01866.html");
	rd.include(request, response);
}
 
Example 13
Source File: BenchmarkTest00004.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00004", "color");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/trustbound-00/BenchmarkTest00004.html");
	rd.include(request, response);
}
 
Example 14
Source File: BenchmarkTest01869.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest01869", "whatever");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/weakrand-04/BenchmarkTest01869.html");
	rd.include(request, response);
}
 
Example 15
Source File: TiposAtividadesControle.java    From redesocial with MIT License 5 votes vote down vote up
private void criarNovo(HttpServletRequest request, HttpServletResponse response) throws Exception{
    try {
        TiposAtividades tiposAtividades = new TiposAtividades();

        request.setAttribute("atividade", tiposAtividades);
    } catch (Exception ex){
        request.setAttribute("erro", ex.getMessage());
    }

    RequestDispatcher rd = request.getRequestDispatcher("paginas/tiposAtividades.jsp");
    rd.forward(request, response);
}
 
Example 16
Source File: BenchmarkTest00992.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00992", "color");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/trustbound-00/BenchmarkTest00992.html");
	rd.include(request, response);
}
 
Example 17
Source File: AbstractBaseFragment.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Service provided by the fragment. This is the entry point of each
 * framgent. It generally includes a JSP page to render a certain part of
 * web viewer.
 * 
 * @param request
 *            incoming http request
 * @param response
 *            http response
 * @exception ServletException
 * @exception IOException
 */
public void service( HttpServletRequest request,
		HttpServletResponse response ) throws ServletException, IOException, BirtException
{
	doPreService( request, response );
	doService( request, response );
	String target = doPostService( request, response );

	if ( target != null && target.length( ) > 0 )
	{
		RequestDispatcher rd = request.getRequestDispatcher( target );
		rd.include( request, response );
	}
}
 
Example 18
Source File: BenchmarkTest00970.java    From Benchmark with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	javax.servlet.http.Cookie userCookie = new javax.servlet.http.Cookie("BenchmarkTest00970", "ECHOOO");
	userCookie.setMaxAge(60*3); //Store cookie for 3 minutes
	userCookie.setSecure(true);
	userCookie.setPath(request.getRequestURI());
	response.addCookie(userCookie);
	javax.servlet.RequestDispatcher rd = request.getRequestDispatcher("/cmdi-01/BenchmarkTest00970.html");
	rd.include(request, response);
}
 
Example 19
Source File: HALoadBalancerServlet.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Strip off the <code>/LBS</code> prefix from the requestURI and forward
     * the request to the servlet at the resulting requestURI. This forwarding
     * effectively disables the LBS but still allows requests which target the
     * LBS to succeed against the webapp on the same host.
     * <p>
     * Note: If the deployment is does not support HA replication (e.g., either
     * not HA or HA with replicationFactor:=1), then we still want to be able to
     * forward to the local service.
     * 
     * @param request
     *            The request.
     * @param response
     *            The response.
     * 
     * @throws IOException
     * @throws ServletException
     * 
     * @see <a href="http://trac.blazegraph.com/ticket/965" > Cannot run queries in
     *      LBS mode with HA1 setup </a>
     */
    public void forwardToLocalService(//
            final boolean isLeaderRequest,//
            final HttpServletRequest request, //
            final HttpServletResponse response//
    ) throws IOException {

        final String path = request.getRequestURI();

        // The prefix for the LBS servlet.
        final String prefix = (String) request.getServletContext()
                .getAttribute(BigdataServlet.ATTRIBUTE_LBS_PREFIX);

        if (prefix == null) {
            // LBS is not running / destroyed.
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        if (!path.startsWith(prefix)) {
            // Request should not have reached the LBS.
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        // the full LBS prefix (includes /leader or /read).
        final String full_prefix = getFullPrefix(isLeaderRequest, prefix);

        // what remains after we strip off the full LBS prefix.
        final String rest = path.substring(full_prefix.length());

        // build up path w/o LBS prefix.
        final StringBuilder uri = new StringBuilder();
        
        if (!rest.startsWith("/")) {
            /*
             * The new path must start with '/' and is relative to this
             * ServletContext.
             */
            uri.append("/");
        }

        // append the remainder of the original requestURI
        uri.append(rest);
        
//        // append the query parameters (if any).
//        final String query = request.getQueryString();
//        if (query != null)
//            uri.append("?").append(query);

        // The new path.
        final String newPath = uri.toString();
        
        /*
         * Forward the request to this servlet container now that we have
         * stripped off the prefix for the LBS.
         */

        // Get dispatched for the new requestURL path.
        final RequestDispatcher requestDispatcher = request
                .getRequestDispatcher(newPath);

        try {

            nforward.increment();
            
            if (log.isInfoEnabled())
                log.info("forward: " + path + " => " + newPath);

            // forward to a local servlet.
            requestDispatcher.forward(request, response);
            
        } catch (ServletException e) {
            
            throw new IOException("Could not forward: requestURL=" + path, e);
            
        }

    }
 
Example 20
Source File: InternalResourceView.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Obtain the RequestDispatcher to use for the forward/include.
 * <p>The default implementation simply calls
 * {@link HttpServletRequest#getRequestDispatcher(String)}.
 * Can be overridden in subclasses.
 * @param request current HTTP request
 * @param path the target URL (as returned from {@link #prepareForRendering})
 * @return a corresponding RequestDispatcher
 */
@Nullable
protected RequestDispatcher getRequestDispatcher(HttpServletRequest request, String path) {
	return request.getRequestDispatcher(path);
}