Forward and Redirect difference

xiaoxiao2021-03-30  198

date

August 13, 2005

Author

gauss

Types of

JSP

content

Forward with Redirect

Forward

With redirect

In the front desk development process, you may often encounter the operation of forwarding pages, it is obvious that Forward and Redirect, but which one is used, what is the difference between them, now I will understand my own understanding and How to apply when developing is written for everyone to refer to:

(1) Common:

They have implemented pages implemented according to their own conditions.

(2) difference

category

concept

Share data

application

REDIRECT

URL re-direction: can be any URL

Can't share data in Request

Generally used to return to the main page and jump to other websites when the user logs in

Forward

Page Forwarding: Only other web components of the same web application

Forwarding the page and forwarding the page to the data in common request

Generally used for user login, forward to the corresponding module according to the role, etc.

(3) Example:

For example, the client accesses index.jsp with xxx / index.jsp? Name = GAUSS & PWD = 123, and the in Index.jsp can be passed in login.jsp. getParameter () gets Name and PWD, and <% response.sendredirect ("login.jsp");%>

(4) Pay attention

Generally, there is a page DEFAULT.JSP submitted data before the index.jsp page, then the data submitted by the defaultl.jsp page can be obtained in the login.jsp page, not the data submitted by the index.jsp page, the index.jsp page is just The execution is a forwarding operation. Of course, it can be added to the business operation. He can get the request data, use XXX / INDEX.JSP? Name = GAUSS & PWD = 123, login is omitted to omit the previous page in front of Index.jsp. Submitted data

转载请注明原文地址:https://www.9cbs.com/read-130497.html

New Post(0)