1. Forward request jump
Request. getrequestdispather (""). forword (request, response );
Features:
(1) the address bar remains unchanged. Cause: Because the address bar remains unchanged after the jump, the address before the jump is refreshed, or the page before the jump is refreshed, the form will be submitted repeatedly when the form is submitted, A big problem may occur.
(2) values can be transferred across pages. For example, request. setattribute ("MSG", "incorrect user name or password") in. jsp before the jump ");
Request. getattribute ("MSG") in. jsp after the jump ");
In this way, the MSG "incorrect user name or password" before the jump can be passed to the page after the jump.
Note:
(1) The attribute names before and after the transfer must be the same. Otherwise, an nullpointerexception exception occurs because the corresponding value is not obtained.
(2) You must setattribute before getattribute. Otherwise, an nullpointerexception exception occurs.
2. Redirect jump
Response. sendredirect ("");
Features:
(1) Changing the address bar will not cause repeated submission of forms
(2) values cannot be transferred across pages. If you want to pass the value, you can use URL rewriting.
For example, before the jump: Response. sendredirect ("index. jsp? Code = "1001 ");
After jump: String code = request. getparameter ("Code ");
Note: The passed values must have the same name. For example, the names in this example are all codes.
Each of the two methods has its own advantages and disadvantages.