Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

life span of HttpServletRequest and HttpServletResponse

 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I was wondering about the life time of a HttpServletRequest object. I think it is longer than that of a HttpSession object, since a HttpSession is stored in a HttpServletRequest object. Then when is HttpServletRequest destroyed or expire?
On the same token, how long is the life span of a HttpServletResponse object? When will it expire?
 
Chris Stehno
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The lifetime of an HttpServletRequest object is a single request (which may include forwarding to another page). The lifetime of an HttpSession object is dependent on the server settings (usually about 15min or less - for a single user session).
I think what may be confusing you is the reference to the session object from within the request. The current user session is associated with the request, but is not part of the request. The actual session objects are managed by the session manager part of the servlet container.
Hope this clears things up

------------------
Chris Stehno (Sun Certified Programmer for the Java 2 Platform)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic