title: using jsp to check username and password
body: <p>Hello i'm learning a bit JSP and i have a problem with the code below. I create one index.jsp file and try to run it with eclipse or directly with Tomcat 6.0. I always get a <strong>error</strong> for the line "<strong>if (name.equals("user") &amp;&amp; password.equals("1234"))</strong>". The error is 
  <strong>java.lang.NullPointerException</strong>. I would be glad for any advise.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
            "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"&gt;
  
  &lt;head&gt;
    &lt;title&gt;Practice&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;h2&gt;Practice&lt;/h2&gt;
  &lt;h3&gt;Please enter your name and the password.&lt;/h3&gt;
  &lt;form method="post" action=""&gt;
    &lt;table&gt;
  &lt;tr&gt;&lt;td style="text-align:center"&gt;Name&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="name" size="80" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td style="text-align:center"&gt;Password&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="password" size="80" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="Send" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="reset" value="Reset" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;%-- Testing name and password. --%&gt;
  &lt;% String name = request.getParameter("name");
     String password = request.getParameter("password");
     if (name.equals("user") &amp;&amp; password.equals("1234"))
       {
  %&gt;
         &lt;p&gt;Your Input is correct!&lt;/p&gt;
  &lt;%   }
     else if (!name.equals(""))
       {
  %&gt;
         &lt;p&gt;Please enter your name!&lt;/p&gt;
  &lt;%   }
  
     else if (!password.equals(""))
       {
  %&gt;
         &lt;p&gt;Please enter your password!&lt;/p&gt;
  &lt;%   }
  
     else if (!name.equals("") &amp;&amp; !password.equals(""))
       {
  %&gt;
         &lt;p&gt;Please enter your name and your password!&lt;/p&gt;
  
  &lt;%   }
  
     else
       {
  %&gt;
         &lt;p&gt;Your input is not correct!&lt;/p&gt;
  &lt;%   }
  %&gt;
  
  &lt;/body&gt;
  
  
  &lt;/html&gt;
  </code></pre>