Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between forwarding and redirection [duplicate]

Possible Duplicate:
difference between jsp forward and redirect

Does anyone knows the differences between forwarding and redirection in Http servlets and the impact of these differences on browser refreshes?

like image 394
dali1985 Avatar asked Dec 27 '11 16:12

dali1985


2 Answers

forwarding is done without letting client know that, It is used to do internal communication at server, while in redirecting we are asking client go back and ask it over here.


Real life example

Forwarding

You went to postoffice there are number of boxes and person sitting there, now one of them accepts your request and it internally forwards it to other responsible person to fulfil your request and at the end of the process you will get the result

Redirecting

now the same person gives you a token which says goto window no5 and ask that person .

Also See

  • difference-between-jsp-forward-and-redirect
like image 175
jmj Avatar answered Oct 20 '22 10:10

jmj


Read this wikipedia article, which explains it very clearly.

A forward just transfers the responsibility of a single request handling to a new server-dide component (example: servlet --> JSP). A redirect asks the browser to send a new request when a first one has been partially handled (example :create product --> redirect to list of products).

The post-redirect-get pattern, which is explained in the wikipedia article, explains when and why a redirect is preferrable.

like image 32
JB Nizet Avatar answered Oct 20 '22 10:10

JB Nizet