permaculture playing cards
The moose likes Servlets and the fly likes Query regarding Response.sendRedirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Query regarding Response.sendRedirect" Watch "Query regarding Response.sendRedirect" New topic

Query regarding Response.sendRedirect

Manish Jaju

Joined: Jul 21, 2004
Posts: 24
During response.sendRedirect, How client comes to know that it has to again make a new request. How that Information is sent to client(for making a new request). Can anybody clarify this.
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
It is the job of the developer to re-direct the browser to the new location.

At most, you can provide a link on the page where the client can click if the page doesn't get displayed automatically in, say, a few seconds.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

When you call sendRedirect the server sends two header variables that tell the client's browser what to do:

The first is a 302 (Moved Temporarily) status code.
The other is the "Location" value containing the page to which the browser is to be redirected.

[ April 11, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

hi i have a doubt when the user use SendRedirect(...newPage.jsp);
will the newPage.jsp will contain the data in req
Let me know the funtionality......
i mean data that we store in req while travesing the pages...

say if u have 4 pages while

page 1 ---> page2 ---> page3
due to some problem u are redirecting the client req so that req goes to new page...
while crawling the page1 thru page 3 if store data in req will i get in transfeed page

Thanks, Ganesh Gowtham
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

No, with sendRedirect, each page will have a new request object.
If you want to retain your objects across requests, you would need to bind them to session scope.
I agree. Here's the link:
subject: Query regarding Response.sendRedirect
It's not a secret anymore!