I used this method and the commented once but it did not work , the print method work properly but the redirection didn't.
else if (action.contentEquals("Login"))
{
RequestDispatcher view = request.getRequestDispatcher("mainPage.html");
try {
System.out.print("Login now");
view.forward(request, response);
} catch (ServletException e1) {
System.out.print("Error Loging in");
}
/*try {
System.out.print("Login now");
response.sendRedirect("mainPage.html");
return;
} catch (IOException e) {
System.out.print("Error"); }
*/
}
You can get some ideas here:
Redirecting a calling JSP to itself using RequestDispatcher object
RequestDispatcher view = request.getRequestDispatcher("mainPage.html");
try {
System.out.print("Login now");
view.forward(request, response);
response.sendRedirect("mainPage.html");
} catch (ServletException e1) {
System.out.print("Error Loging in");
}
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.