• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can destroy() method can be called explicitly

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
something is there ...as I have bet with somebody...and pls let me know !
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic