| Author |
Explicitly instance of Servlet
|
Rahul Juneja
Ranch Hand
Joined: Aug 03, 2002
Posts: 425
|
|
Can anybody tell me whether we can Explicitly create the instance of a Servlet.I mean 1)'Not by Calling Servlet first time or 2) Load on Startup'. Does anybody know can we create an instance of Servlet without these options. This question was asked to me in an interview. Thanks, Rahul [ June 11, 2004: Message edited by: Rahul Juneja ]
|
Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
|
 |
Ivor Lithan
Greenhorn
Joined: May 30, 2004
Posts: 10
|
|
Not quite sure what you mean, but if you mean what I think you do, you could do : or am I missing what you are asking?
|
 |
Rahul Juneja
Ranch Hand
Joined: Aug 03, 2002
Posts: 425
|
|
Thanks Dear, I was asking the same but one more Question which comes in my mind is that what is the practical implementation of this. Can you please give me some idea about that. thanks, Rahul Juneja
|
 |
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
|
|
Well, a servlet is just a Java class that happens to implement a particular interface. There's nothing to stop you (other than the potential for confusing a reader, and other issues of general good design) from giving it a "main" method, and/or a constructor, and creating an instance of it in the way you would any other Java object. Of course, if you create an instance of a servlet class yourself, there will be no container that knows about it, so it will never receive HTTP requests, but I gues that's not what you want, is it?
|
A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
|
 |
Ivor Lithan
Greenhorn
Joined: May 30, 2004
Posts: 10
|
|
Dear??? Well, the one time I used that was when I had a servlet that implemented runnable, with the idea being I could have a thread running and then query it through the web front end - and this servlet was kicked off by a scheduler that I had written - and so it used that bit of code to start it all off - other than that I've never used it for anything
|
 |
 |
|
|
subject: Explicitly instance of Servlet
|
|
|