Hey guys,
I'm usually pretty good with this stuff, but Servlets are kicking my ass. The logic all seems straightforward enough, but I can't figure out the environment.
Here's my setup: running Tomcat through XAMPP and using port 9999. The files themselves are all in a Dropbox folder. So the root here is: C:\Dropbox\xampp\tomcat\webapps\servletprojects
For this particular servlet, it's part of a larger project that also has some Javascript elements with some HTML pages and a style sheet. That is in:
C:\Dropbox\xampp\tomcat\webapps\servletprojects\Hi gherNumbersProject
Under that, I have the folder C:\Dropbox\xampp\tomcat\webapps\servletprojects\Hi gherNumbersProject\WEB-INF and within there I have C:\Dropbox\xampp\tomcat\webapps\servletprojects\Hi gherNumbersProject\WEB-INF\classes
Inside the WEB-INF folder I have my web.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>ProcessLogin</servlet-name> <servlet-class>process_login</servlet-class> </servlet> <servlet-mapping> <servlet-name>ProcessLogin</servlet-name> <url-pattern>/process_login</url-pattern> </servlet-mapping> </web-app>
Inside the classes folder I have process_login.class
And here is the code for my servlet. There's not much there yet, I just want to get text on the web browser screen.
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class process_login extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); out.println("Hello!"); } }
So then I tell Eclipse to build the file. It generates the process_login.class file. I can't figure out how to get Eclipse to put it into the \WEB-INF\classes folder... it puts it in the project's main folder C:\Dropbox\xampp\tomcat\webapps\servletprojects\Hi gherNumbersProject right next to the process_login.java file. I've just been copying the .class file over manually. Any advice on how to get Eclipse to put the .class file where I want it is appreciated. But that isn't my main issue.
Lastly I point Firefox over to http://localhost:9999/servletproject.../process_login
But all I get is a 404 page:
Am I fundamentally misunderstanding the setup of servlets? Or is there some mundane detail I am missing?HTTP Status 404 - /servletprojects/HigherNumbersProject/process_login
type Status report
message /servletprojects/HigherNumbersProject/process_login
description The requested resource is not available.
Apache Tomcat/7.0.30
This is really frustrating because I like to think I'm a pretty smart guy and I can figure this stuff out with enough effort, but I am absolutely hitting a wall here and burning off a lot of time. It's part of a larger class project which is due in 3 weeks. Though.... thank God I already got the Javascript, basic HTML layouts, and styling done. If I can clear this hurdle and just get the stupid servlets working I think I can plow through the internal code logic fairly quickly.