| |

VerySource

 Forgot password?
 Register
Search
View: 822|Reply: 5

The difference between request forwarding and redirection?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-8 10:30:01
| Show all posts |Read mode
I just started learning j2ee, the difference between 'redirection' and 'request forwarding' is always unclear, and when should I use 'redirection' and when should I use 'request forwarding'? Shrimp helped explain it in detail, I am grateful.
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-3-31 01:15:01
| Show all posts
Redirection is actually two requests,
The first time, the client requests A, the server responds, and the response comes back, telling the browser that you should go to B. At this time IE can see that the address has changed, and the historical back button is also lit.

So the code is response.sendRedirect (.....)

Forwarding is the internal transfer of the request / response processing right to another server.
For the client, it only knows the A that it requested first, and not the middle B, or even C, D ...
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-11 09:45:01
| Show all posts
Still don't quite understand, can you elaborate more? Please ...
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-4-12 21:45:01
| Show all posts
Suppose you go to apply for a license,

Redirection: You went to Bureau A first, and the people in Bureau A said, "This matter is not ours to go to, Bureau B." Then, you withdrew from A and went to Bureau B by car.

Forwarding: You went to Bureau A first. After watching Bureau A, you know that this matter should actually be managed by Bureau B, but instead of returning you, he asked you to sit for a while and went to the back office to contact the person of B, After letting them do it, they sent it over.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-14 18:30:01
| Show all posts
Another big difference is that redirects can access resources outside of your web application
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-1 14:30:02
| Show all posts
The difference between redirection and forwarding:
1. Redirect access to the server twice, and forward access to the server only once.
2. Redirecting can see the URL of the target page, and forwarding can only see the URL of the page visited for the first time. The server will do all the work in the future.
3. Return must be added after the redirection. Otherwise, although the page is redirected, the statement after the redirection will be executed. The forwarding is the execution of the redirection page, and the following code will not be executed.
4. Use information sharing at the request level, using redirection will inevitably go wrong! ! !
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list