This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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)