aspose file tools*
The moose likes Servlets and the fly likes Difference Between Client side Redirect and Server Side Redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference Between Client side Redirect and Server Side Redirect" Watch "Difference Between Client side Redirect and Server Side Redirect" New topic
Author

Difference Between Client side Redirect and Server Side Redirect

sirisha makkapati
Ranch Hand

Joined: Dec 10, 2006
Posts: 83
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

Joined: Oct 20, 2006
Posts: 61
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

Joined: Nov 16, 2005
Posts: 502

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.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
vishnu
Greenhorn

Joined: Nov 28, 2006
Posts: 5
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

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Difference Between Client side Redirect and Server Side Redirect