Binding user objects to request,session,pagecontext, application
Alok Pota
Ranch Hand
Joined: Mar 07, 2001
Posts: 185
posted
0
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
posted
0
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
posted
0
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
subject: Binding user objects to request,session,pagecontext, application