wood burning stoves*
The moose likes Servlets and the fly likes Binding user objects to request,session,pagecontext, application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Binding user objects to request,session,pagecontext, application" Watch "Binding user objects to request,session,pagecontext, application" New topic
Author

Binding user objects to request,session,pagecontext, application

Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
Are user objects bound to the request, session, pagecontext, application objects of a JSP stored in the Java heap? The servlet API offers some control over session bound objects why is there no control provided for page/application and request bound objects?
When do all these objects become available for GC?.
Bharatesh H Kakamari
Ranch Hand

Joined: Nov 09, 2000
Posts: 198
They are stored in heap. But when they should be garbage collected depends on the implementor of JSP Engine.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Alok Pota:
Are user objects bound to the request, session, pagecontext, application objects of a JSP stored in the Java heap? The servlet API offers some control over session bound objects why is there no control provided for page/application and request bound objects?
When do all these objects become available for GC?.

These objects are stored where you allocate all Java objects -- which, indeed, is the heap.
With "control" I assume you mean HttpSessionBindingListener. The reason you need it is that a session can be expired anytime by the server. The lifecycle of all other scopes is a lot more predictable:

  • Page scoped objects are essentially local variables, they are released when you leave the page.
  • Request scoped objects are released when you've reached the last servlet in the chain processing the request.
  • Application scoped objects stay around until the server reclaims the ServletContext (usually only when it is shut down). I think this is the only one where you might wish for a HttpSessionBindingListener equivalent.

  • When these objects are eligible for garbage collection is not up to the implementor of the JSP engine, but defined in the JSP specification. When the garbage collection actually happens is undetermined, as always.
    - Peter
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Binding user objects to request,session,pagecontext, application
 
Similar Threads
Implicit objects in Servlets
About PageContext
JSP implicit objects?
Q from Hanu's mock test
Thread Safe objects of jsp