简体   繁体   中英

How can I dispatch from Registration Servlet to Login Servlet POST method

how to redirect the request from registration servlet to login servlet POST method . i wanna do this because the user after registration, i redirect him to the homepage as already logged.

here is my Registration servlet

     -------
    response.setContentType("text/html");
    String nome=request.getParameter("Nome");
    String cognome=request.getParameter("Cognome");
    String email=request.getParameter("Email");
    String password=request.getParameter("Password");
    String documento=request.getParameter("Documento");
    String num_documento=request.getParameter("NumeroDocumento");

    Utente u = new Utente(email,password,nome,cognome,documento,num_documento);
    System.out.println("qui");

    RequestDispatcher d;
    UtenteDAO ud = new UtenteDAO();
    if(ud.doSave(u)){
        d = request.getRequestDispatcher();
        d.forward(request, response);
        }else{
            request.setAttribute("err", true);
            d=request.getRequestDispatcher("Registrazione.jsp");
            d.forward(request, response);
        }

}

sorry for my English :(

You can set the response of your servlet to status code 301. Something like below.

response.sendRedirect("https://www.google.com");

This will instruct the browser to go to www.google.com, you can replace this with your URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM