• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it necessary that an entry be made in web.xml for every servlet

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Is it necessary that an entry be made in web.xml for every servlet ?
I believe that an entry in web.xml is required only if the Servlet needs initilization parameters?
Apart from this is there any situation which demands the need for an entry in web.xml??
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible, but not advisable to run servlets without mapping them in your deployment descriptor (web.xml).

In Tomcat, you do this by re-enabling the invoker servlet (which is commented out in TOMCAT_HOME/conf/web.xml). You read why it's a bad idea here:
http://jakarta.apache.org/tomcat/faq/misc.html#evil
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben, why not go ahead help him pull the trigger now that you've given him the gun to put to his head?

Seriously, though, it is highly advisable NOT to enable the "invoker" servlet. Alternatively, you could look at XDoclet if you don't like writing web.xml files. XDoclet will generate them for you based on javadoc tags in your code...
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
Ben, why not go ahead help him pull the trigger now that you've given him the gun to put to his head?


He has given him the gun with a User Guide/Reference Manual (as provided a link on, why not).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic