Implement a form that jumps from a JSP page to Servlet2,servlet2 jumps to Servlet3,servlet3 to get the input parameters:
Jsp:
Xml
Servlet2:
Servlet3:
wherein, in using Method 1:
Response.sendredirect ("Servlet3"), you can only implement jumps from Servlet2 to Servlet3,
It is not possible to pass the values of username and password.
In Use Method 2:
RequestDispatcher rd=request.getrequestdispatcher ("Servlet3");
Rd.forword (Request,response);
You can implement a servlet jump, and if you want to pass in a parameter, you must also have a Servlet3
String Username=request.getparameter ("username", username);
String password=request.getparameter ("password", password);
This can be achieved by HttpSession accept parameters
In the Servlet2:
HttpSession session=request.getsession ();
Session.setattribute ("username") can pass data into
In the Servlet3:
Receive with Session.getattribute ("username")
Note, however, that the resulting object is to be converted to a string type
解决中文乱码的问题: 输入有中文: request.setCharacterEncoding("utf-8"); 输出有中文: response.setCharacterEncoding("uft-8"); response.setContentType("text/html;charset=utf-8");
servlet implementation of data transmission and garbled solution