File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Enthuware Q Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Enthuware Q" Watch "Enthuware Q" New topic
Author

Enthuware Q

deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
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

Joined: May 30, 2007
Posts: 189
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

Joined: Jul 25, 2008
Posts: 124
how should be 3 one is right??

why not option 1 is correct??
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Really So confusing question. I also read this questionin some site. Can some one explain all options clearly.


SCJP 5 |SCWCD 5| Started thinking about Web Services ?
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
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 ]

SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
Bala'J'i Rags
Greenhorn

Joined: Jul 29, 2008
Posts: 26
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 ]

SCJP 1.5,SCWCD 1.5
Bala'J'i
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Hi Sandeep ,

thanks for the good explanation.

I not clear about option 5. Can you please give some more inputs ..
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
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

Joined: Apr 16, 2004
Posts: 201
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enthuware Q