• Post Reply Bookmark Topic Watch Topic
  • New Topic

URL to servlet?  RSS feed

 
imre leber
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most books on servlets seem to say that the URL to a servlet is:
http://<servername>/<webappname>/servlet/<servletname>
but that does not seem to work (in tomcat 5.0), doing it the more intuitive way:
http://<servername>/<webappname>/<servletname>
however seems to work. Does anybody know what is up with this?
 
joseph corner
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
AFAIK, you set the URL of your servlet in the web.xml file in your web module, using the <url-pattern> tag. if you put /servlet/yourServlet inside that tag, that will be URL to use in your browser.
Cheers,
J
 
Gowrishankar Mudaliar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you configure a servlet name in web.xml, then you use the url like
http://<server>/<webapp>/<servletName>
Otherwise, the default way is to use the fully qualified name
http://<server>/<webapp>/<servlet>/[<packageName>][.]servletClassName
Note: contents within [] are optional.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!