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 Wonder about one of the SCWCD whizlabs question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Wonder about one of the SCWCD whizlabs question?" Watch "Wonder about one of the SCWCD whizlabs question?" New topic
Author

Wonder about one of the SCWCD whizlabs question?

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
I read in one of the whizlabs mock exams, is that the servlet can have more than one instance. The container might choose to do that, when the servlet implements the SingleThreadModel interface. Is this true of false??


SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Yes, its true. Here are the excerpts from the spec -

For a servlet not hosted in a distributed environment (the default), the servlet container must use only one instance per servlet declaration. However, for a servlet implementing the SingleThreadModel interface, the servlet container may instantiate multiple instances to handle a heavy request load and serialize requests to a particular instance.

In the case where a servlet was deployed as part of an application marked in the deployment descriptor as distributable, a container may have only one instance per servlet declaration per Java Virtual Machine (JVMTM). However, if the servlet in a distributable application implements the SingleThreadModel interface, the container may instantiate multiple instances of that servlet in each JVM of the container.

The use of the SingleThreadModel interface guarantees that only one thread at a time will execute in a given servlet instance�s service method. It is important to note that this guarantee only applies to each servlet instance, since the container may choose to pool such objects. Objects that are accessible to more than one servlet instance at a time, such as instances of HttpSession, may be available at any particular time to multiple servlets, including those that implement SingleThreadModel.
It is recommended that a developer take other means to resolve those issues instead of implementing this interface, such as avoiding the usage of an instance variable or synchronizing the block of the code accessing those resources. The SingleThreadModel Interface is deprecated in this version of the specification.


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
Thanks Niranjan very much for this detailed explanation.
I guess I am using an older version of the Whizlabs simulator that is targeted to an older version of the SCWCD. I see questions talking about taglib tag in the deployment descriptor. When I open the Netbeans IDE , I dont see any taglib intellesense in the deplyment descriptor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wonder about one of the SCWCD whizlabs question?