With the response.sendredirect to do is to send a special header to the browser, and then the browser to do the turn, go to the specified page, so when using Sendredirect, the browser's address bar can see changes in address.
With <jsp:forward page= ""/> is different, it is done directly in the server, the browser does not know, also does not deal with the browser, this from the browser address does not change can be seen.
So you need to pay attention to the following two points when using Response.sendredirect:
1, when using Response.sendredirect, the front cannot have HTML output.
This is not absolute, and the inability to have HTML output actually means that HTML cannot be sent to the browser. In fact, the server now has the cache mechanism, generally in 8K (I mean JSP SERVER), which means that unless you close the cache, or you use the Out.flush () force refresh, then before using Sendredirect, A small amount of HTML output is also allowed.
If the error says, "Some information has been submitted" (the original forgotten), then you should pay attention to see, the front is not too much HTML output.
2, after Response.sendredirect, should be followed by a return;
We already know that Response.sendredirect is a browser to do the steering, so only after the page processing is complete, there will be actual action. Now that you've got to turn, then what's the point of the output? And it is possible that the subsequent output will cause the steering failure.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.