title: Using if-else in JSP
body: <p>I'm using the following code to print the name of the user on the browser:</p>
  
  <pre><code>&lt;body&gt;
    &lt;form&gt;
      &lt;h1&gt;Hello! I'm duke! What's you name?&lt;/h1&gt;
      &lt;input type="text" name="user"&gt;&lt;br&gt;&lt;br&gt;
      &lt;input type="submit" value="submit"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
      &lt;input type="reset"&gt;
    &lt;/form&gt;
    &lt;%String user=request.getParameter("user"); %&gt;
    &lt;%if(user == null || user.length() == 0){
      out.print("I see! You don't have a name.. well.. Hello no name");   
     }
     else {%&gt;
        &lt;%@ include file="response.jsp" %&gt;
     &lt;% } %&gt;  
  &lt;/body&gt;
  </code></pre>
  
  <p>response.jsp:</p>
  
  <pre><code>&lt;body&gt;
      &lt;h1&gt;Hello&lt;/h1&gt;
      &lt;%= request.getParameter("user") %&gt;
   body&gt;
  </code></pre>
  
  <p>Every time I execute it, the message</p>
  
  <blockquote>
    <p>I see! You don't have a name.. well.. Hello no name</p>
  </blockquote>
  
  <p>gets displayed even though I haven't entered anything in the textbox. However if I enter anything in it, then the response.jsp code is displayed, but I don't want the first message to be displayed on execution. How do I make that happen? Please suggest changes in my code.</p>
  
  <p>P.S. I had read in some questions that instead of checking for equality with null, one must check it for not equals, so that it doesn't throw null pointer exception. when I tried the same, i.e. <code>if(user != null &amp;&amp; ..)</code>, I got <code>NullPointerException</code>.</p>