Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat - servlet - packages ???

 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi:
If I have a servlet in a package say:
abdc.efgh
and I have added the file in the web-inf\classes\abcd\efgh\MyServlet.class
1. How do I access the servlet from the browser? http://localhost:8080/MyProject/servlet/MyServlet
2. What should be my context in the server.xml
file?

Is the docBase correct?
Thanks.
- satya
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The context in server.xml just establishes a "application context" - your WEB-INF/classes etc directory has to be based in that context.
Study the way the examples context is created in Tomcat
<Context path="/examples"
docBase="webapps/examples"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
and the path to class files in the examples application is
tomcat/webapps/examples/WEB-INF/classes
With the html files in various directories off the docbase
tomcat/webapps/examples
Bill

------------------
author of:
 
Xinbo Cheng
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't you access your servlet the following way:
http://localhost:8080/MyProject/servlet/abcd.efgh.MyServlet
? (I'm just asking a question not posting an answer)
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Xinbo:
Thanks for your msg. Thats what I was looking for.
That works perfectly.
regds.
- satya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic