here's my code:

import java.io.*; 
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;


public class HelloWorld extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello Programmers!!! ");

to access it on Tomcat, i goto :

so i guess @WebServlet is supposedly required to do the mapping for a servlet other wise we could have done manually in the web.xml file in the WEB-INF directory

and oh, my directory tree:


so my HelloWorld is placed in classes folder as you can see

and you have seen my code and my use of @WebServlet annotation.

but when i goto localhost:8080/examples/HW i get 404 error

The requested resource (/examples/HW) is not available.

what am i doing wrong??

tomcat - 7.0.11
servlet version - dunno.. shouldn't it be latest coz i'm using the servlet-api.jar provided by tomcat. so if tomcat is 7.x,so should servlet be latest too right?
i mean its not giving any error about the annotation tag at compilation

Edited by ronnieaka: n/a

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.