wood burning stoves 2.0*
The moose likes Servlets and the fly likes can i create object for our own servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "can i create object for our own servlet" Watch "can i create object for our own servlet" New topic

can i create object for our own servlet

sujitha reddy

Joined: Oct 20, 2006
Posts: 15
this is madhu

can i create a object of our own servlet class.What is the use of that object.
[ October 20, 2006: Message edited by: Bear Bibeault ]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Servlet is not special java class.You can create a servlet object.but that you cannot expect to work as a servlet.

Rahul Bhattacharjee
LinkedIn - Blog
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12759
Just to expand on what Rahul said, instances of a servlet are created and managed by a servlet container. This is similar to the way instances of an applet are created and managed by a browser.

Because servlet operation depends on the servlet context, request, response, etc etc provided by the container, there is nothing to be gained by creating one outside the container envrironment. Although I have seen servlet classes with a main method so they can be executed directly, this is a symptom of bad architecture.

Don't get me started about those stupid light bulbs.
subject: can i create object for our own servlet
Similar Threads
very very imp. for any devolopment interview..
Session Object
writing own constructor for servlet
How can we create our own String class in java?
Creating new Locale Object