Wednesday, May 28, 2008

Java Tricky Questions - 2

How can you create multiple servlet objects of the same servlet class if You are not allowed to implements the SingleThreadModel interface ??

Ans :
More than one element is defined in the web.xml file having the same servlet class names.
( some of you may say the ans is stupid ... I mean ques is more literal than technical ... but hey it can be a twister for many )

Practical Use :
You can do this if you want to have multiple sets of initialization parameters. For example, you may want one instance to connect to one database and a second instance to connect to another database.

No comments: