• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

destroy() method

 
Nauman Khan
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt in the anwer of below mentioned question which i picked from jdiscuss.com.
As for jdiscss,the answer is 3 and 4. But I'm not sure,please anybody know the better discription,let me know.
Problem

Assuming that the Servlet Container has just called the destroy() method of a servlet instance, which of the following statements are correct?


Options

Select 2 correct options.

1.Any resources that this servlet might hold have been released.
2.The servlet container time out has exceeded for this servlet instance.
3.The init() method has been called on this instance.
4.None of the requests can EVER be serviced by this instance.
5.All threads created by this servlet are done.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any resources that this servlet might hold have been released.

False: destroy() gives the servlet an opportunity to clean up any resources that are being held.
The servlet container time out has exceeded for this servlet instance.

Partly true. Another reason is that all threads within the servlet's service method have exited.
The init() method has been called on this instance

True: If init didn't work, then there would not be a servlet in service to start with.
None of the requests can EVER be serviced by this instance

True, the servlet container will not call the service method again on this servlet.
All threads created by this servlet are done

Partly true. Another reason is that a timeout period has passed. This may have been set in the deployment descriptor like this (for 30 minutes):
<session-config>
<session-timeout>30</session-timeout>
</session-config>
Also, the HttpSession interface has a method to set a session invalidated period (in seconds):
setMaxInactiveInterval(3600)
[ September 24, 2003: Message edited by: Roger Chung-Wee ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic