aspose file tools*
The moose likes JSP and the fly likes How can destroy() method can be called explicitly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How can destroy() method can be called explicitly" Watch "How can destroy() method can be called explicitly" New topic
Author

How can destroy() method can be called explicitly

amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
Hi,
I just wanted to know how can the jspdestroy() or in servlet destroy()
method can be called other then, when servlet container shuts down !!

suppose in a case when we have intialised resourse in init() or jspInit() method and the jsp/servlet is served once then not been request for many days and resourse are loaded on memory and using memory! then in that case how can we remove the servlet/jsp from container ?

is there something like time-out ?
kindly tell me

Regards
Amit


Thanks and Regards, Amit Taneja
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

No, you leave the container deal with the servlets' lifecycle.
I don't know if there are some kind of configuration for this, it may depend on the container you are using.


[My Blog]
All roads lead to JavaRanch
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
something is there ...as I have bet with somebody...and pls let me know !
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Call to Destroy method of servlet is taken care by the container,special thing is we can also call destroy method but there is difference between the programmatic call and container call.

Container call only release the all resources used by the servlet and our programmatic call execute as ordinary method call and doesnot release the resources allocated by the container.

Is this thing you are looking for??
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by amit taneja:

suppose in a case when we have intialised resourse in init() or jspInit() method and the jsp/servlet is served once then not been request for many days and resourse are loaded on memory and using memory! then in that case how can we remove the servlet/jsp from container ?


According to the spec, servlet containers are free to unload servlets to recover resources and then reload them if needed.

These are issues for the developers of the container itself; not for application developers. All we need to know is that the destroy method is there for us to put clean up code that needs to be called when the servlet is destroyed.

If you have a JSP page that consumes so much memory that you need to explicitly load and unload it, you might want to re-think your architecture.
The servlet spec provides methods and objects that give you very fine grained control over the life cycle of beans and helper objects.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
Originally posted by Ben Souther:


According to the spec, servlet containers are free to unload servlets to recover resources and then reload them if needed.


If you have a JSP page that consumes so much memory that you need to explicitly load and unload it, you might want to re-think your architecture.
The servlet spec provides methods and objects that give you very fine grained control over the life cycle of beans and helper objects.


how can we explicitly load and unload it... thats what i m asking
kindly reply with full answer or give me the link

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I don't know of any spec compliant way to do this and I don't think there is one.

This is not something that you should need to do in the first place.
The point of high level APIs (such as Servlets and JSP) is to shield application developers from such things.
Again, if you find yourself in need of such capabilities, you might want to re-think your application's architecture.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How can destroy() method can be called explicitly