title: HTTP Status 404 - The requested resource is not available. =>the servlet exists in web.xml
body: <p>I receive the error "HTTP Status 404 - /Servlet/NotaControllerServlet</p>
  
  <p>type: Status report
  message: /Servlet/NotaControllerServlet
  description: The requested resource is not available" </p>
  
  <p>when I try to run my webApp. Here is my code:</p>
  
  <p><strong>1. NoteDAO</strong></p>
  
  <pre><code>package DAO;
  import org.hibernate.HibernateException;
  import org.hibernate.Query;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.Configuration;
  
  import java.util.*;
  
  import Entities.*;
  
  public class NoteDAO {
      private static List&lt;Nota&gt; result;
      static Configuration configuration=new Configuration().configure();
      static SessionFactory sessionFactory=configuration.buildSessionFactory();
      static Session session=sessionFactory.openSession();
      static Transaction tx=session.beginTransaction();
  public void addNota(int nota, int id_elev, int id_materie) {
          try {
  
              tx=session.beginTransaction();
              Elev elev = new Elev();
              elev.setId_elev(id_elev);
              Materie mat = new Materie();
              mat.setId_materie(id_materie);
  
              Nota newNota = new Nota();
              newNota.setNota(nota);
              newNota.setElev(elev);
              newNota.setMaterie(mat);
              session.save(newNota);
              tx.commit();
  
          } catch (HibernateException ex) {
              ex.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p><strong>2. Servlet</strong></p>
  
  <pre><code>package Servlet;
  
  import java.io.IOException;
  import java.util.List;
  
  import DAO.*;
  import Entities.*;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  
  
  public class NotaControllerServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      protected Elev getElev(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
          Elev elv = null;
          String elev = request.getParameter("nume_elev");
          List&lt;Elev&gt; listElevi = EleviDAO.getEleviByName(elev);
          for (Elev el : listElevi) {
              elv = el;
          }
          return elv;
      }
  
      protected Materie getMaterie(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
          Materie mat = null;
          String materie = request.getParameter("materie");
          List&lt;Materie&gt; listMaterie = MaterieDAO.getMaterieByName(materie);
          for (Materie mate : listMaterie) {
              mat = mate;
          }
          return mat;
      }
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          doPost(request, response);
      }
      protected void doPost(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
          int id_elev = getElev(request, response).getId_elev();
          int id_materie = getMaterie(request, response).getId_materie();
          int nota = Integer.parseInt(request.getParameter("nota"));
  
              HttpSession session=request.getSession(true);
          try {
              NoteDAO notaDAO = new NoteDAO();
              notaDAO.addNota(nota, id_elev, id_materie);
              response.sendRedirect("AddNota.jsp");
          }
  
          catch (Exception e) {
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p><strong>3. JSP</strong></p>
  
  <blockquote>
     
    
    <p>
    "http://www.w3.org/TR/html4/loose.dtd"></p>
    
    <p></p>
    
    <p>  &lt;%@page import="java.util.<em>, Entities.</em>, DAO.<em>,
    Servlet.</em>;"%> 
      </p>
    
    <p>Adauga nota</p>
    
    <p>   $(function() {      var spinner =
    $("#spinner").spinner();  });       </p>
  
  <pre><code>  &lt;h1&gt;Adauga nota&lt;/h1&gt;
  
    &lt;%          List&lt;Elev&gt; list = EleviDAO.getElevi();          List&lt;Materie&gt; mat =
  </code></pre>
    
    <p>MaterieDAO.getMaterie();      %></p>
  
  <pre><code>  &lt;table cellpadding="3"&gt;             &lt;tr&gt;
            &lt;td&gt;Nume_elev&lt;/td&gt;
            &lt;td&gt;&lt;select name="nume_elev"&gt;
  
                    &lt;%
                        for (Elev el : list) {
                    %&gt;
                    &lt;Option value="&lt;%=el.getNume_elev()%&gt;"&gt;&lt;%=el.getNume_elev()%&gt;&lt;/Option&gt;
                    &lt;%
                        }
                    %&gt;
            &lt;/select&gt;&lt;/td&gt;          &lt;/tr&gt;
  
        &lt;tr&gt;
            &lt;td&gt;Nume_materie&lt;/td&gt;
            &lt;td&gt;&lt;select name="materie"&gt;
                    &lt;option value="Select materie"&gt;Select materie&lt;/option&gt;
                    &lt;%
                        for (Materie ma : mat) {
                    %&gt;
  
                    &lt;Option value="&lt;%=ma.getDenumire_materie()%&gt;"&gt;&lt;%=ma.getDenumire_materie()%&gt;&lt;/Option&gt;
                    &lt;%
                        }
                    %&gt;
            &lt;/select&gt;&lt;/td&gt;          &lt;/tr&gt;
  
        &lt;tr&gt;
            &lt;td&gt;Nota:&lt;/td&gt;
            &lt;td&gt;&lt;input id="spinner" name="nota"&gt;&lt;/td&gt;           &lt;/tr&gt;
  
    &lt;/table&gt;
  
    &lt;p /&gt;       &lt;input type="submit" value="Adauga nota" /&gt; &lt;input
  </code></pre>
    
    <p>type="reset"          value="Reseteaza  formular" /></p>
    
    <p>  </p>
  </blockquote>
  
  <p><strong>4. WEB.xml</strong></p>
  
  <pre><code>&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app
  &gt; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  &gt;   xmlns="http://java.sun.com/xml/ns/javaee"
  &gt;   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  &gt; http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    version="2.5"&gt;
  &gt; 
  &gt;   &lt;servlet&gt;       
  &gt;       &lt;display-name&gt;Note&lt;/display-name&gt;
  &gt;       &lt;servlet-name&gt;Note&lt;/servlet-name&gt;
  &gt;       &lt;servlet-class&gt;Servlet.NotaControllerServlet&lt;/servlet-class&gt;
  &gt;   &lt;/servlet&gt;      
  &gt;   &lt;servlet-mapping&gt;   
  &gt;       &lt;servlet-name&gt;Note&lt;/servlet-name&gt;
  &gt;       &lt;url-pattern&gt;/AddNota&lt;/url-pattern&gt;     
  &gt;   &lt;/servlet-mapping&gt;
  </code></pre>
  
  <blockquote>
    <p></p>
    
    <p>Thank you for your help!</p>
  </blockquote>