JSP redirection and forwarding are both request methods in JSP, which can be used according to different situations.
Recommended courses: Java tutorial
Forwarding:
When the client request is submitted to the server's jsp for processing
This jsp can carry the request and response objects and transfer them to another place in the web application for processing
After processing at another place, the result page response is generated to the client browser
At this time, the client browser can see the result page, but the URL has not changed
So I don’t know how many layers of processing the server has gone through
Redirect:
When the client browser submits it to the server's JSP for processing
This JSP returns a response: to request another URL
At this time, the client browser will send it again A new request goes to this new address
The new URL address is responsible for generating a response for the browser
The URL the browser sees at this time is the URL address corresponding to the second request
The difference between the two
Selection of forwarding and redirection
Redirection is slower than forwarding because the browser You have to issue a new request. If it doesn't matter whether you use forwarding or redirection, it is recommended to use forwarding.
Because forwarding can only access the current WEB application, so when accessing between different WEB applications, especially when accessing resources on another WEB site, you can only use redirection at this time. .
The above is the detailed content of What are JSP forwarding and redirection. For more information, please follow other related articles on the PHP Chinese website!