Meaningless Drivel is fun!
The moose likes Tomcat and the fly likes 404 Error - Can't access Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "404 Error - Can Watch "404 Error - Can New topic

404 Error - Can't access Servlet

Brendon Lippy

Joined: Jun 01, 2003
Posts: 1
I'm trying to build a basic servlet using Apache Tomcat 5.0. I made a simple servlet:
import javax.servlet.*;
import javax.servlet.http.*;
public class Test extends HttpServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
PrintWriter out = response.getWriter();
out.println("Hello World!..");
} /* doGet */
} /* Test */

I compiled this class, and put the .class file into the ROOT/WEB-INF/classes. I tried to access this servlet through a browser using the following URL: http://localhost:8080/servlet/Test
I get the 404 error (cannot access resource). What am I doing wrong?

Lets Face it.. Not all of us are Java Gurus
Jason Brawner
Ranch Hand

Joined: Dec 19, 2001
Posts: 66
Did you add the servlet to your deployment descriptor (web.xml)?

Jason E. Brawner<br />Sun Certified Java Programmer<br />Sun Certified Web Component Developer
I agree. Here's the link:
subject: 404 Error - Can't access Servlet
jQuery in Action, 3rd edition