• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets and session question

 
Bilal Ali
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my question is that whether I'd face a problem in maintaining the session for a user if I use response.sendRedirect. Is there a possibility for the session to be lost ? If so, why ? I am asking this question because some years back I have read in some book of servlet that in redirecting the "request" object is lost
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Requests and sessions are two different scopes. Because a redirect causes a new request to be issued, yes, any scoped variables in the previous request are lost. This does not apply to the session, whose purpose for being is to retain state over multiple requests.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!