This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello, I've been trying to learn to use servlets but I've unfortunately hit a roadblock. I'm pretty sure I've defined by web.xml correctly, but I'm getting a 404 when I try to access my servlet. I can go to index.jsp just fine, but not any of the servlets that I've tried. I'm using Tomcat and Eclipse, if it matters. No errors appear in the tomcat logs.
I guess the weird thing is that this behavior seems to be inconsistent. The 404 happens when I deploy the application by creating an XML file with a docBase and a path in TOMCAT_HOME\conf\Catalina\localhost. However, when I use the Eclipse plugin to deploy the app (the plugin points to the same TOMCAT_HOME above) or if I build a war file and drop it into TOMCAT_HOME\webapps, the above behavior is reversed. I can access the servlet but not any of my static files (JSPs, HTMLs, etc.). Has anyone encountered this behavior? I've been stuck for days.
Follow the directory structure to run your servlet application ( I think)
place your jsp/html in web (not in web-inf)
web.xml in web-inf
servlets/java in src
Hope this works..
Correct me if anything wrong.