Home > front end >  About the servlet redirects
About the servlet redirects

Time:09-23

The servlet forword/include and sendredirect cannot use at the same time?
After use the include jump to serlvet2 servlet1 and by servlet2 jump to another JSP page,

If you can, why the following code can't jump? Click on the HTML button in the address bar shows that servlet1 url, the page has no content (normal) direct access to the JSP page
Servlet1:
@ Override
Protected void doPost (it request, HttpServletResponse response) throws ServletException, IOException {
//TODO Auto - generated method stub
Request. SetCharacterEncoding (" utf-8 ");
The response. SetCharacterEncoding (" utf-8 ");
The response. SetContentType (" text/HTML; charset=utf-8");
Request. GetRequestDispatcher ("/servlet2 "). The include (request, response);
}
Servlet2:
Protected void doPost (it request, HttpServletResponse response) throws ServletException, IOException {
//TODO Auto - generated method stub
Response. SendRedirect (request. GetContextPath () + "/demo JSP"));
}

CodePudding user response:

Why don't you look at the console and abnormality
  • Related