title: Apache Tomcat 7 - The requested resource is not available
body: <p>I'm getting an error in my browser when trying to run a servlet. It says </p>
  
  <blockquote>
    <p>The requested resource is not available.</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>"HTTP Status 404-". The console doesn't print any errors but one
    warning: " [SetPropertiesRule]{Server/Service/Engine/Host/Context}
    Setting property 'source' to 'org.eclipse.jst.jee.server:CDM' did not
    find a matching property."</p>
  </blockquote>
  
  <p>It feels like I've tried everything to get it to work so I'm open to any suggestion that will make my code work.</p>
  
  <p><strong>StudentResultRegistered.java</strong></p>
  
  <pre><code>package com.cdm;
  
  
  import java.io.*;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  
  import javax.servlet.*;
  import javax.servlet.annotation.*;
  import javax.servlet.http.*;
  
  
  
  
  @WebServlet(name="studentResultRegistered",urlPatterns={"/herpDerp"})
  public class StudentResultRegistered extends HttpServlet {
  
  
  
      @Override
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
  
      String s=request.getParameter("studentID");  
      String k=request.getParameter("kursKod");  
      String t=request.getParameter("termin");  
      String p=request.getParameter("provNr"); 
      String b=request.getParameter("betyg"); 
  
  
  
      try{
          Class.forName("com.mysql.jdbc.Driver");
          Connection con = DriverManager.getConnection("jdbc:mysql://localhost/school_server", "testuser", "testuser");
  
  
  
          String sql = "INSERT INTO regStudentResult (studentID, kursKod, termin, provNr, betyg)" +
                  "VALUES (?, ?, ?, ?, ?)";
  
          PreparedStatement ps = con.prepareStatement(sql);
  
          ps.setString(1,s);  
          ps.setString(2,k);  
          ps.setString(3,t);  
          ps.setString(4,p);
          ps.setString(5,b);
  
          int i=ps.executeUpdate();  
          if(i&gt;0)  
          out.print("success");  
      }catch (Exception e2) {System.out.println(e2);}  
  
      out.close();  
      } 
  
  
  }//studentResultRegistered
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Course Data Management&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Registrera Resultat&lt;/h1&gt;
  
  &lt;FORM ACTION="/studentResultRegistered" method="get"&gt;
    StudentID:
    &lt;INPUT TYPE="TEXT" NAME="studentID" VALUE=""&gt;&lt;BR&gt;
  
    Kurskod:
    &lt;INPUT TYPE="TEXT" NAME="kursKod" VALUE=""&gt;&lt;BR&gt;
  
    Termin:
    &lt;INPUT TYPE="TEXT" NAME="termin" VALUE=""&gt;&lt;BR&gt;
  
    ProvNr:
    &lt;INPUT TYPE="TEXT" NAME="provNr" VALUE=""&gt;&lt;BR&gt;
  
    Betyg:
    &lt;INPUT TYPE="TEXT" NAME="betyg" VALUE=""&gt;&lt;BR&gt;
  
  
      &lt;INPUT TYPE="SUBMIT" VALUE="Registrera Resultat"&gt;
  &lt;/FORM&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;CDM&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;  
    &lt;/welcome-file-list&gt;
  
  
  
   &lt;servlet&gt;
      &lt;servlet-name&gt;studentResultRegistered&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.cdm;&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;studentResultRegistered&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/herpDerp&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>