Two Laptop Bag*
The moose likes Servlets and the fly likes sendRedirect() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "sendRedirect()" Watch "sendRedirect()" New topic
Author

sendRedirect()

VENKATESH NADAGOUDA
Greenhorn

Joined: Jan 29, 2003
Posts: 7
Does using sendRedirect() end a session, if so how to retain the same session
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
no, it does not.
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
Hi Venkatesh
A session is started when the first request is received from a client, and ends when the same client explicitly ends the session or the server does not receive any further requests from the client for a certain period of time (which can be configured in the web.xml file). The servlet itself can also invalidate a session itself using HttpSession.invalidate().
sendRedirect() merely directs the client to another resource. It does commit the response to the client, but it does not end the session itself.
[ January 29, 2003: Message edited by: mark howard ]
VENKATESH NADAGOUDA
Greenhorn

Joined: Jan 29, 2003
Posts: 7
can we use pageContext.getOut().print("Hi") in doAfterBody() method.
VENKATESH NADAGOUDA
Greenhorn

Joined: Jan 29, 2003
Posts: 7
thanks Howard and Boyet
Sudd Ghosh
Ranch Hand

Joined: Oct 23, 2002
Posts: 187
Hi Venkatesh -
Yes, in the doAfterBody() method you can use the getOut() method on the PageContext object that you've already saved using the setPageContext(). Pls note you don't have the implicit variable pageContext available in the tag handler class. It seems whatever you can do in doStartTag() can be done in doAfterBody(), however in the case when some body-content is present, the calling sequence will differ.
Thanks, Sudd


SCJP 1.4, SCWCD, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sendRedirect()