Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference Between Client side Redirect and Server Side Redirect

 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a dfoubt We will say sendRedirct() is Client side Redirect and RequestDispatcher() is Server Side Redirct How they both will work exactly.


Any One Please.......


Thank uuuuu
 
Dhanya Palanisamy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forward and Redirects: The forward and redirect operations both replace content. The current page or output stream is terminated, and is replaced with the output of the specified page.

Forwards: Both <jsp:forward> and RequestDispatcher.forward() are what I refer to as "server-side" redirects. The redirect operation is performed in the server side, and the browser is unaware of the change. If page1.jsp forwards to page2.jsp, the browser's address bar will still show page1.jsp

Redirects: The response.sendRedirect() is what I call a "client-side" redirect. The redirect operation is passed to the browser, which is aware of the change. If page1.jsp redirects to page2.jsp, the browser's address bar be updated to show page2.jsp.

Forwards vs. Redirects: You choose between forwards and redirects depending on how you want the browser to be affected. Forward operations are faster, because all the processing happens server-side. Redirect operations update the browser history, however, which is often desirable.

If you forward between page1 and page2, if the user's clicks the "refresh" or "reload" button, both page1 and page2 are executed a second time. On the other hand, if you use a client-side redirect, the browser's address information is updated. If the user clicks refresh, only page2 are re-executed.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sendRedirct() : server sends HTTP response code 302 with the URL of new location which you pass as parameter to sendRedirct() method to the Client. Client will know "what is happening?".


forward() : Server transfers control to the Resource you pass as a parameter to RequestDispatcher. Client will not know about this.
 
vishnu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sirisha
redirect means the control will goes to anothre url for example mailcity.com is one famous site that will be purchesed by lycos.com when ever the user login to the mailcity.com the request will goes to lycos or it will give status code as 302.requestdispatcher will have two methods include() & forward(),In forward the control will goes to another jsp,and in include just we will include jsp.

thanks,
vishnu.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vishnu,
Welcome to JavaRanch!

We're pleased to have you here with us in the servlets forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here


It looks like you've already been asked to change it 3 times.
Your account will be closed very shortly if the screen name is not updated.
[ December 19, 2006: Message edited by: Ben Souther ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vishnu", your final warning was delivered in this topic.

Your account has been disabled.

Should you wish to reinstate your account, you must contact me via email.

bear
JavaRanch Sheriff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic