title: HTTP Error 404 The requested resource is not available, Glassfish
body: <p>when ever I press the submit action button to send the information to a controller i always get "HTTP 404 Status - not found: The requested resource is not available" I was just wondering if any could help me sort out this frustrating problem. Here is my Code: </p>
  
  <p>LibraryInfo.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &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;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Library Information&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="/bookServlet" method="POST"&gt;
      &lt;fieldset style="width:300px"&gt;
      &lt;legend&gt;Find Book&lt;/legend&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;ISBN Number:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="isbn" required="required"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
                  &lt;input type="submit" value="Find Book"/&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Book.java: </p>
  
  <pre><code>package com.farmani.model;
  
  public class Book {
      private int isbn;
      private String author; 
      private String title; 
      private String status;
      public int getIsbn() {
          return isbn;
      }
      public void setIsbn(int isbn) {
          this.isbn = isbn;
      }
      public String getAuthor() {
          return author;
      }
      public void setAuthor(String author) {
          this.author = author;
      }
      public String getTitle() {
          return title;
      }
      public void setTitle(String title) {
          this.title = title;
      }
      public String getStatus() {
          return status;
      }
      public void setStatus(String status) {
          this.status = status;
      } 
  
  }
  </code></pre>
  
  <p>ConnectionClass.java</p>
  
  <pre><code>package com.farmani.dao;
  
  import java.sql.Connection;
  import java.sql.SQLException;
  
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.sql.DataSource;
  
  public class ConnectionClass {
      private DataSource dataSource; 
      public ConnectionClass(){
          try{
              InitialContext context = new InitialContext(); 
              dataSource = (DataSource)context.lookup("jdbc/employee"); 
          }catch(NamingException ex){
              ex.printStackTrace(); 
          }
      }
      public Connection getConnection(){
          Connection conn = null; 
          try{
              conn=dataSource.getConnection(); 
          }catch(SQLException ex){
              ex.printStackTrace(); 
          }
          return conn; 
      }
  }
  </code></pre>
  
  <p>LibraryDAO.java</p>
  
  <pre><code>package com.farmani.dao;
  
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  
  import com.farmani.model.Book;
  
  public class LibraryDAO {
      private Connection connection; 
      public LibraryDAO(){
          ConnectionClass conn = new ConnectionClass(); 
          connection = conn.getConnection(); 
      }
      public Book getBookByISBN(int isbn){
          Book bk = new Book(); 
          try{
              PreparedStatement preparedStatement = connection.prepareStatement("select * from book where ISBN=?");
              preparedStatement.setInt(1,isbn);
              ResultSet rs = preparedStatement.executeQuery(); 
              if(rs.next()){
                  bk.setIsbn(rs.getInt("ISBN"));
                  bk.setAuthor(rs.getString("author"));
                  bk.setTitle(rs.getString("title")); 
                  bk.setStatus(rs.getString("status")); 
              }
          }catch(SQLException e){
              e.printStackTrace();
          }
          return bk;
      }
  
  }
  </code></pre>
  
  <p>bookServlet.java:</p>
  
  <pre><code>package com.farmani.controllers;
  
  import java.io.IOException;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import com.farmani.dao.LibraryDAO;
  import com.farmani.model.Book;
  
  
  @WebServlet("/bookServlet")
  public class bookServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
      private static String BOOK_DETAILS="/LibraryDetails"; 
      private LibraryDAO dao; 
  
  
      public bookServlet() {
          super();
          dao = new LibraryDAO(); 
      }
  
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          int isbn = Integer.parseInt(request.getParameter("isbn")); 
          Book bk = dao.getBookByISBN(isbn); 
          request.setAttribute("Book",bk); 
          RequestDispatcher view = request.getRequestDispatcher(BOOK_DETAILS); 
          view.forward(request,response); 
      }
  
  }
  </code></pre>
  
  <p>Web.xml:</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://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
    &lt;display-name&gt;LibraryWeb&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;LibraryInfo.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>LibraryDetails.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &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;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Book Details&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;CENTER&gt;&lt;h1&gt;&lt;b&gt;Book Details&lt;/b&gt;&lt;/h1&gt;&lt;/CENTER&gt;
  &lt;ul&gt;
  &lt;li&gt;ISBN: ${Book.isbn}&lt;/li&gt;
  &lt;li&gt;Author: ${Book.author}&lt;/li&gt;
  &lt;li&gt;Title: ${Book.title }&lt;/li&gt;
  &lt;li&gt;Status: ${Book.status}&lt;/li&gt; 
  &lt;/ul&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>