This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
Hi, I have created a simple servlet and was able to deploy it to the Tomcat examples folder. Modified web.xml to contain the servlet and servlet-mapping tags for my HelloWorld servlet. I wanted to deploy it into another directoy so at the same level as examples forlder in Tomcat I created a folder called test and placed a web.xml plus the classes into that folder. The directory structure for my demo folder is
demo ---WEB-INF ----classes web.xml
in my web.xml I have <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>HelloServlet</servlet-class> </servlet>
but I cannot get to the servlet, I keep getting a HTTP 404, the requested resource (demo/servlet/HelloServlet) is not available. the URL I am entering is http://localhost:8080/demo/servlet/HelloServlet
can anyone help??
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
Is the HelloServlet class part of a package named "servlet"? If not, leave out the "servlet" from the URL and mapping.
In general you should avoid URLs that start with "servlet", because that looks like you might be using the InvokerServlet, which is not a good idea for the reasons explained on that page.
I tried that and still I get a HTTP 404 error The requested resource (/HelloServlet) is not available.
Im a bit stumped as it works fine in the examples directory. I must be doing something really stupid...
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12265
1
posted
0
Im a bit stumped as it works fine in the examples directory.
Probably the web.xml for your example folder has the "invoker" servlet turned on. The invoker is able to look for servlet classes that are not in a formal package (the "default" package).
However, the normal JVM class loader can NOT cope with this. ALL classes used in servlets should be put in a package. Trust me - this forum is littered with threads where people found this out the hard way.
Your web.xml would then give a complete package for servlet-class and the compiled class would be located accordingly under WEB-INF/classes