• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enthuware Q

 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that the Servlet Container has just called the destroy() method of a servlet instance, which of the following statements are correct?

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.

Answer please.
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answers:
3.The init() method has been called on this instance.
4.None of the requests can EVER be serviced by this instance.

correct me If I am wrong.
 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how should be 3 one is right??

why not option 1 is correct??
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really So confusing question. I also read this questionin some site. Can some one explain all options clearly.
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that the Servlet Container has just called the destroy() method of a servlet instance, which of the following statements are correct?

1.Any resources that this servlet might hold have been released. some resources (may be I/O or databases) may not be freed by the servlet.


2.The servlet container time out has exceeded for this servlet instance. That's not the only way a servlet's destroy method is called.


3.The init() method has been called on this instance. That's for sure because then it doesn't make sense to call destroy


4.None of the requests can EVER be serviced by this instance.Don't say that you don't agree.


5.All threads created by this servlet are done. Well it can be bad luck for some threads.



Hope that makes it clear.
[ August 06, 2008: Message edited by: Sandeep Bhandari ]
 
Bala'J'i Rags
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My option would be 3,4,

while 1 is tricky.. resource getting cleaned up depends on the coding done in the Destroy method..

and option 5 is not clear..and i guess its not right as well
[ August 06, 2008: Message edited by: Bala'J'i Rags ]
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandeep ,

thanks for the good explanation.

I not clear about option 5. Can you please give some more inputs ..
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chintu sirivennela:
Hi Sandeep ,

thanks for the good explanation.

I not clear about option 5. Can you please give some more inputs ..


Multiple threads are created for users when they try accessing it. This means that the instance data is same for each user. You can verify it by using a class level counter and incrementing it every time someone hits the servlet.
Now a servlet thread may be servicing while the the servlet's destroy method was deliberately called.
The idea is we can't be sure that all threads have done their processing. Its same as if all the simple java threads are not done and you shut down the JVM.
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this may not confuse you. Here's what the specification says:

Before the servlet container can call the destroy method, it must allow any threads that
are currently running in the service method of the servlet to either complete, or exceed a
server defined time limit, before the container can proceed with calling the destroy
method.

Once the destroy method is called on a servlet instance, the container may not route any
more requests to that particular instance of the servlet. If the container needs to enable the
servlet again, it must do so with a new instance of the servlet´┐Żs class.

[ August 07, 2008: Message edited by: Sandeep Bhandari ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic