title: Two forms but only 1 jsp file
body: <p>Here's what I've got going on.  I have one .jsp file.  However, I have two forms with multiple inputs inside those forms.</p>
  
  <p>What is the best way to detect that one form was submitted but not the other?  Here's an example:  I have this form: </p>
  
  <pre><code>&lt;form  name = "login" action="index.jsp" method="get"&gt;
  Username: &lt;input id="username" name="username" type="text"/&gt;&lt;br/&gt;
  Password: &lt;input id="password" name="password" type="password"/&gt;
  &lt;input type="submit" Value="Login" &gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>If that button is clicked, I'd like to run this code:</p>
  
  <pre><code>String username = request.getParameter("username");
  String password = request.getParameter("password");
  if((username!= null &amp;&amp; !username.trim().equals("")) &amp;&amp; (password != null &amp;&amp; !username.trim().equals(""))) {
      DBentry DBentry=new DBentry();
      boolean flag = DBentry.isTaken(username);
      if(flag) {%&gt;&lt;script type="text/javascript"&gt;alert("Login Successful!");&lt;/script&gt;&lt;%
          }
      else { %&gt;&lt;script type="text/javascript"&gt;alert("Unrecognized username.  Please register!");&lt;/script&gt;&lt;% }
      }
  else { %&gt;&lt;script type="text/javascript"&gt;alert("Please enter both a username and password!");&lt;/script&gt;&lt;% }
  </code></pre>
  
  <p>Further down I would have something exactly like it but submitting a different form.
  Thanks!</p>