title: Servlet: HTTP Status 404 - Not Found
body: <p>My Servlet doesn't work at all. I'm getting HTTPS Status 404- Not Found. Below is the complete code for the same:-</p>
  
  <p>index.jsp    </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
        &lt;html&gt;
            &lt;head&gt;
                &lt;title&gt;Page title&lt;/title&gt;
                &lt;meta charset="UTF-8" /&gt;
           &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
           &lt;link href="CSS/cssSheet.css" rel="stylesheet"  type="text/css" /&gt;
       &lt;/head&gt;
       &lt;body&gt;
  
           &lt;nav&gt;
               &lt;a href="ControlleurSimple?action=apropos" target="_self"&gt;A propos&lt;/a&gt;
           &lt;/nav&gt;
  
           &lt;main&gt;
               &lt;h1&gt;Welcome&lt;/h1&gt;
               Text here
  
           &lt;/main&gt;
      &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;ControllerSimple&lt;/servlet-name&gt;
          &lt;servlet-class&gt;WebApplication1.ControllerSimple&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;ControllerSimple&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/ControllerSimple&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>ControllerSimple.java</p>
  
  <pre><code>package WebApplication1;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  
  public class ControllerSimple extends HttpServlet {
  
      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          try (PrintWriter out = response.getWriter()) {
              /* TODO output your page here. You may use following sample code. */
              out.println("&lt;!DOCTYPE html&gt;");
              out.println("&lt;html&gt;");
              out.println("&lt;head&gt;");
              out.println("&lt;title&gt;Servlet ControllerSimple&lt;/title&gt;");            
              out.println("&lt;/head&gt;");
              out.println("&lt;body&gt;");
              out.println("&lt;h1&gt;Servlet ControllerSimple at " + request.getContextPath() + "&lt;/h1&gt;");
              out.println("&lt;/body&gt;");
              out.println("&lt;/html&gt;");
          }
      }
  
  
      @Override
      public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          String action = request.getParameter("action");
  String jspPage = "/index.html";
  if ((action == null) || (action.length() &lt; 1)) {
   action = "default";
  }
  if ("apropos".equals(action)) {
   jspPage = "/apropos.jsp";
  }
  RequestDispatcher rd = request.getRequestDispatcher(jspPage);
  rd.forward(request, response);
  
      }
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          processRequest(request, response);
      }
  
      @Override
      public String getServletInfo() {
          return "Short description";
      }// &lt;/editor-fold&gt;
  
  }
  </code></pre>
  
  <p>apropos.jsp</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Title&lt;/title&gt;
          &lt;meta charset="UTF-8" /&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
          &lt;link href="CSS/cssSheet.css" rel="stylesheet"  type="text/css" /&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;main&gt;
              Text
  
          &lt;/main&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm new to the servlet, so maybe I would have missed something. When I click on the link, I have the "HTTP Status 404 - Not Found " error. I really don't understand what I did wrong.</p>
  
  <p>I'm using NetBeans IDE 8.2 and GlassFish 4.1.1</p>