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

[543 byte] By [ajith_guesta] at [2007-11-27 5:25:05]
# 1
You can't. How else could the webcontainer know about the existence of a servlet? What exactly do you want to achieve? Maybe there are other solutions.
BalusCa at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

tolmanka at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
tomank is right about Tomcat; you'll need to get the Invoker servlet uncommented first. http://nogoodatcoding.googlepages.com/deployingaservletontomcat
nogoodatcodinga at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
thanks buddy ...
ajith_guesta at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

appy77a at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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?

BalusCa at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

appy77a at 2007-7-12 14:44:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...