Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when would a servlet be destroyed

 
Sathvathsan Sampath
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • 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...?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When taken out of service, for example when we stop our web application.
 
Mohnish Chaudhary
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Aniruddha Mukhopadhyay
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Jack Wiesenthaler
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your answer was reasonable.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you deploy a new one? You can do that without stopping the server, right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic