• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

when would a servlet be destroyed

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was faced with this question and answered it saying whenever the servlet container deemed necessary - during shutdown or when it needs to free memory resources. However, the interviewer wasn't not satisfied with this response.
Thoughts...?
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When taken out of service, for example when we stop our web application.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sathvathsan, your reply was correct. It's when either the servlet is destroyed or when the servlet container has to do it to free some resources.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet container shutting down definitely calls the destroy method of servlet. If servlet container needs some free memory, it would call destroy method for those servlets whose service method have exited or after a timeout period has passed.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sathvathsan Sampath:
I was faced with this question and answered it saying whenever the servlet container deemed necessary - during shutdown or when it needs to free memory resources. However, the interviewer wasn't not satisfied with this response.
Thoughts...?



What do you mean when you say he wasn't satisfied?
What was his reaction to your answer?
 
Sathvathsan Sampath
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

By Ben Souther
What was his reaction to your answer?


He responded asking, �Besides a shut down or freeing memory resources when exactly would the container destroy a servlet?�
He wanted me to be very specific and detailed. I didn't have a clue. He believed I just scratched the surface saying the above. When I asked him what his response would be to this he refused to answer! I want to understand how more there is to this.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He may have wanted you to say:
Before the webapp is reloaded or stopped and before the contextDestroyed event of any context listeners is fired.

He may also have wanted to see if you would mistakenly say:
Whenever servletDestroyed is called.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think your answer was reasonable.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you deploy a new one? You can do that without stopping the server, right?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic