title: HTTP Status 404 Servlet-The requested resource is not available
body: <p>I am making one simple program to take few fields as input and then after clicking on confirm button confirm.jsp will appear. </p>
  
  <p>I have created Controller.java servlet to identify the button clicked and then open the jsp. 
  Controller.java is stored in directory WEB-INF/classes/ch2/servletController and submit.jsp,register.jsp,confirm.jsp are stored in /ch2/servletController directory. </p>
  
  <p>Whenever i click on confirm button, i get below error. WebApplication is the name of my project. I am using netBeans IDE. </p>
  
  <p>HTTP Status 404 - /WebApplication/ch2/servletController/Controller </p>
  
  <p>type Status report </p>
  
  <p>message /WebApplication/ch2/servletController/Controller </p>
  
  <p>description The requested resource is not available. </p>
  
  <p>Please find below web.xml,servlet and all the jsp files.. </p>
  
  <p><strong>register.jsp</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;  
  &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//EN"&gt;  
  &lt;html&gt;  
  &lt;head&gt;  
  &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt;  
  &lt;title&gt;Register&lt;/title&gt;  
  &lt;/head&gt;  
  &lt;body&gt;  
  &lt;form method="get" action="Controller"&gt;  
  &lt;p&gt;&lt;b&gt;E-store&lt;/b&gt;&lt;/p&gt;  
  &lt;br&gt;  
  &lt;br&gt;  
  &lt;p&gt;Enter First Name: &lt;input type="text" name="FirstName" value="${param.FirstName}"&gt;&lt;/p&gt;  
  &lt;p&gt;Enter Last Name: &lt;input type="text" name="LastName" value="${param.LastName}"&gt;&lt;/p&gt;  
  &lt;p&gt;Enter Mail-id: &lt;input type="text" name="MailId" value="${param.MailId}"&gt;&lt;/p&gt;  
  &lt;p&gt;Enter PhoneNo: &lt;input type="text" name="PhoneNo" value="${param.PhoneNo}"&gt;&lt;/p&gt;  
  &lt;p&gt;&lt;input type="submit" name="confirmButton" value="confirm"&gt;&lt;/p&gt;  
  &lt;/form&gt;  
  &lt;/body&gt;  
  &lt;/html&gt;  
  </code></pre>
  
  <p><strong>confirm.jsp</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;  
  &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//EN"&gt;  
  &lt;html&gt;  
  &lt;head&gt;  
  &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt;  
  &lt;title&gt;Confirm Details&lt;/title&gt;  
  &lt;/head&gt;  
  &lt;body&gt;  
  &lt;form method="get" action="Controller" &gt;  
  &lt;p&gt;&lt;b&gt;E-store&lt;/b&gt;&lt;/p&gt;  
  &lt;br&gt;  
  &lt;br&gt;  
  &lt;p&gt;First Name: ${param.FirstName}&lt;input type="hidden" name="FirstName" value="${param.FirstName}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;p&gt;Last Name: ${param.LastName}&lt;input type="hidden" name="LastName" value="${param.LastName}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;p&gt;Mail-id: ${param.MailId}&lt;input type="hidden" name="MailId" value="${param.MailId}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;p&gt;PhoneNo: ${param.PhoneNo}&lt;input type="hidden" name="PhoneNo" value="${param.PhoneNo}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;input type="submit" name="EditButton" value="Edit"&gt;  
  &lt;input type="submit" name="Submitbutton" value="Submit"&gt;  
  &lt;/form&gt;  
  &lt;/body&gt;  
  &lt;/html&gt;  
  </code></pre>
  
  <p><strong>submit.jsp</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;  
  &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//EN"&gt;  
  &lt;html&gt;  
  &lt;head&gt;  
  &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt;  
  &lt;title&gt;Confirm Details&lt;/title&gt;  
  &lt;/head&gt;  
  &lt;body&gt;  
  &lt;form&gt;  
  &lt;p&gt;&lt;b&gt;E-store&lt;/b&gt;&lt;/p&gt;  
  &lt;br&gt;  
  &lt;br&gt;  
  &lt;p&gt;Thank You for the registration. Your details have been submitted as follows-&lt;/p&gt;  
  &lt;p&gt;First Name: ${param.FirstName}&lt;input type="hidden" name="FirstName" value="${param.FirstName}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;p&gt;Last Name: ${param.LastName}&lt;input type="hidden" name="LastName" value="${param.LastName}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;p&gt;Mail-id: ${param.MailId}&lt;input type="hidden" name="MailId" value="${param.MailId}"&gt;&lt;/input&gt;&lt;/p&gt;  
  &lt;p&gt;PhoneNo: ${param.PhoneNo}&lt;input type="hidden" name="PhoneNo" value="${param.PhoneNo}"&gt;&lt;/input&gt;&lt;/p&gt;  
  
  &lt;/form&gt;  
  
  &lt;/body&gt;  
  &lt;/html&gt;  
  </code></pre>
  
  <p><strong>Controller.java</strong></p>
  
  <pre><code>package ch2.servletController;  
  import java.io.IOException;  
  import javax.servlet.http.*;  
  import javax.servlet.http.HttpServlet;  
  import javax.servlet.RequestDispatcher;  
  import javax.servlet.http.HttpServletRequest;  
  import javax.servlet.http.HttpServletResponse;  
  import javax.servlet.ServletException;  
  public class Controller extends HttpServlet  
  {  
          @Override  
      protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException  
      {  
          String address=null;  
          if(request.getParameter("confirmButton")!= null)  
          {  
              address="confirm.jsp";  
          }  
          else if(request.getParameter("EditButton")!= null)  
          {  
              address="register.jsp";  
          }  
          else if(request.getParameter("Submitbutton")!=null)  
          {  
              address="submit.jsp";  
          }  
          RequestDispatcher Dispatcher=request.getRequestDispatcher(address);  
          Dispatcher.forward(request, response);  
      }  
  }  
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;  
      &lt;servlet&gt;  
          &lt;servlet-name&gt;FirstController&lt;/servlet-name&gt;  
          &lt;servlet-class&gt;ch2.servletController.Controller&lt;/servlet-class&gt;  
      &lt;/servlet&gt;  
      &lt;servlet-mapping&gt;  
          &lt;servlet-name&gt;FirstController&lt;/servlet-name&gt;  
          &lt;url-pattern&gt;/Controller&lt;/url-pattern&gt;  
      &lt;/servlet-mapping&gt;  
      &lt;session-config&gt;  
          &lt;session-timeout&gt;  
              30  
          &lt;/session-timeout&gt;  
      &lt;/session-config&gt;  
      &lt;welcome-file-list&gt;  
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;  
      &lt;/welcome-file-list&gt;  
  &lt;/web-app&gt;  
  </code></pre>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;  
  &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//EN"&gt;  
  &lt;html&gt;  
  &lt;head&gt;  
  &lt;meta http-equiv="content-type" content="text/html;charset=utf-8"&gt;  
  &lt;title&gt;First JSP&lt;/title&gt;  
  &lt;/head&gt;  
  &lt;body&gt;  
  &lt;form&gt;  
  &lt;p&gt;&lt;b&gt;Welcome to E-store&lt;/b&gt;&lt;/p&gt;  
  &lt;br&gt;  
  &lt;br&gt;  
  &lt;p&gt;Click to &lt;a href="ch2/servletController/register.jsp"&gt;Register&lt;/a&gt;&lt;/p&gt;  
  &lt;/form&gt;  
  &lt;/body&gt;  
  &lt;/html&gt; 
  </code></pre>
  
  <p>I'd be grateful if anyone can help me to solve this problem. </p>
  
  <p>Many Thanks in Advance.</p>