Calling servlet with out entry in web.xml
Hi
I want to know whether can a servlet be invoked with out having an entry in web.xml.Because to my knowledge when ever an entry is made in teh web.xml the <url-pattern> and the class file will be stored as key value combination it is only then when ever a request is made the server gets the class taht is to be invoked from the <url-pattern> that is passed from the client side.
Is ther any way by whihc we can call the servlet directly with out an entry in web.xml
Thanks in advance
Ajithkumar.S
# 2
On Tomcat you can go into the conf/web.xml and uncomment the invoker servlet section. Alternatively you could add the invoker servlet section to the web.xml for your web application. Make sure you also get the servlet mapping section for the invoker servlet.
This will allow you to call you servlet using a url like
http://localhost:8080/myWebApp/servlet/package.class
where package.class is the package and class name of your servlet.
I am not sure if other servers support this but i suspect that they do since this was the original method for accessing servlets.
# 5
I'm quoting from this thread
http://marc.info/?l=tomcat-user&m=118022797828025&w=2
The invoker servlet has been disabled in the default config for ages
(because it is evil :). You can enable it at your own risk in conf/web.xml,
but that isn't recommended. Use an explicit servlet-mapping instead.
# 6
Interesting that it is possible on Tomcat anyway.
What's the real benefit of not having a Servlet definied in web.xml? The only benefit I see is that you don't need to understand/read/change XML when adding or removing a servlet. That isn't worth that imho. What are the other benefits?
# 7
> Interesting that it is possible on Tomcat anyway.
>
> What's the real benefit of not having a Servlet
> definied in web.xml?
>The only benefit I see is that
> you don't need to understand/read/change XML when
> adding or removing a servlet. That isn't worth that
> imho. What are the other benefits?
The only thing I can think of is , to be able to quickly access a Servlet that you've just written, because it takes additional steps to define it in the web.xml.
I think it would be a security concern (of some sort) , if the Servlet's class is known, that's why it is better to access a Servlet with a mapping from web.xml