title: Netbeans error while using servlet
body: <p>I'm new to servlet programming as well as using IDE's for servlet programming. I just installed Netbeans 8.2 for servlet programming and I am getting the following error while executing my servlet program.
  This is my index.html</p>
  
  <pre><code> &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;TODO supply a title&lt;/title&gt;
           &lt;/head&gt;
           &lt;body&gt;
               &lt;h4&gt;Click here to go to &lt;a href="CheckPass"&gt;CheckPass Page&lt;/a&gt;&lt;/h4&gt;
  
  
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my servlet program </p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  public class CheckPass extends HttpServlet
  {
  public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
  {
  response.setContentType("text/html");
  PrintWriter out=response.getWriter();
  out.println("&lt;form name='frm' method='post' action='/WT Practical 2/servlet/CheckPass'&gt;");
  out.println("UserName&lt;input type='text' name='unm'&gt;");
  out.println(" Password&lt;input type='password' name='psw'&gt;");
  out.println(" &lt;input type='submit' value='Login'&gt;");
  out.println("&lt;/form&gt;");
  out.close();
  }
  public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
  {
  PrintWriter out=response.getWriter();
  String unm = request.getParameter("unm");
  String ps=request.getParameter("psw");
  
  if(ps.equals("hello123"))
   out.println("Welcome "+unm);
  else
   out.println("invalid entry");
  }
  
  }
  </code></pre>
  
  <p>This is web.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;CheckPass&lt;/servlet-name&gt;
          &lt;servlet-class&gt;CheckPass&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;CheckPass&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/CheckPass&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt; index.html&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>This servlet is being performed for a college practical of the subject Web Technology so my project name for netbeans is WT Practical 2. Now, this is the error i get</p>
  
  <pre><code>HTTP Status 404 - /WT%20Practical%202/servlet/CheckPass
  
  type Status report
  
  message /WT%20Practical%202/servlet/CheckPass
  
  description The requested resource is not available.
  
  Apache Tomcat/8.0.27
  </code></pre>
  
  <p>I suspect it is because of the line where i gave the path to the form action attribute</p>
  
  <pre><code>&lt;form name='frm' method='post' action='/WT Practical 2/servlet/CheckPass'&gt;
  </code></pre>
  
  <p>What it's expected to do is take user name and password, verify it and give appropriate output depending upon the password. Please help me. Also let me know if my doubt is correct. Also, I've heard that it's not a good practice to write html code in servlet program. I would also like to know how to write the above html code in index.html file instead which should act the same way this program is expected to act. Thanks.</p>