title: How to store usernames and passwords in a very simply registration form using servlet/jsp/javabeans?
body: <p>I understand how to use session cookies to pass a username and password from servlet to servlet but I am baffled on how to store successful registrations so that when someone new registers it checks it against that data store to make sure the username they choose has not already been used.</p>
  
  <p>Keep in mind, none of this has to be secure in any way, it just has to work.</p>
  
  <p>I have a form setup that asks for username, password, and confirm password setup and passes the form data to a servlet named process.</p>
  
  <p>For the life of me I cannot figure out a simple way to make this work without getting into more advanced techniques that require databases or other means. </p>
  
  <p>Here is the code for my form.  Any thing that can point me in the right direction would be of great help.  Thank you.</p>
  
  <pre><code>package HWpackage;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class register extends HttpServlet {
  
  
      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          PrintWriter out = response.getWriter();
          try {
              ///* TODO output your page here
              out.println("&lt;html&gt;");
              out.println("&lt;head&gt;");
              out.println("&lt;title&gt;Servlet register&lt;/title&gt;");  
              out.println("&lt;/head&gt;");
              out.println("&lt;body&gt;");
              out.println("&lt;form action='process' method='post'&gt;");
              out.println("&lt;table border ='5'&gt;" +
                          "&lt;tr&gt;" +
                          "&lt;th colspan='2'&gt;Register Account Information&lt;/th&gt;" +
                          "&lt;/tr&gt;" +
                          "&lt;tr&gt;" +
                          "&lt;td&gt;Requested Username:&lt;/td&gt;" +
                          "&lt;td&gt;&lt;input type='text' name='username' /&gt;&lt;/td&gt;" +
                          "&lt;/tr&gt;" +
                          "&lt;tr&gt;" +
                          "&lt;td&gt;Password:&lt;/td&gt;" +
                          "&lt;td&gt;&lt;input type='password' name='password' /&gt;&lt;/td&gt;" +
                          "&lt;/tr&gt;" +
                          "&lt;tr&gt;" +
                          "&lt;td&gt;Confirm Password:&lt;/td&gt;" +
                          "&lt;td&gt;&lt;input type='password' name='password' /&gt;&lt;/td&gt;" +
                          "&lt;/tr&gt;" +
                          "&lt;tr&gt;" +
                          "&lt;th colspan='2'&gt;&lt;input type='Submit' value='Submit'&gt;&lt;input type='Reset' value='Reset' /&gt;&lt;/form&gt;&lt;/th&gt;" +
                          "&lt;/tr&gt;" +
                          "&lt;/table&gt;");
              out.println("&lt;/body&gt;");
              out.println("&lt;/html&gt;");
              //*/
          } finally { 
              out.close();
          }
      } 
  
      // &lt;editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."&gt;
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          processRequest(request, response);
      } 
  
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          processRequest(request, response);
      }
  
  
      @Override
      public String getServletInfo() {
          return "Short description";
      }// &lt;/editor-fold&gt;
  
  }
  </code></pre>