Servlet object
Hi all,I want to know a simple question as servlet container automatically create object of any servlet when it load a servlet. But my question is can we create a servet object by our own.Please help me regarding this with an examle
# 3
You can.
Servlet servlet = new Servlet();
And now?
Face it, the created servlet is fairly useless. A serlet is created and invoked automatically when you calls it by a URL which matches the url-pattern of the servlet as definied in the web.xml.
What is your goal? What do you want to achieve? Maybe there are cleaner ways.
# 4
> And now?Exactly. Your servlet will never be invoked. Without a container, a servlet is only a servlet in name. Calls to methods such as getServletConfig, getServletContext, getServletInfo, getServletName and log will not work correctly.