title: servlet/jsp , doGet and doPost , registration form
body: <p>I'm writing Blog in java servlet/jsp. And now I have problem with registration. </p>
  
  <p>That's what I have in RegisterServlet</p>
  
  <pre><code>@WebServlet("/register")
  public class RegisterServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, java.io.IOException {
  
  }
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
              ServletException, IOException {
          request.setCharacterEncoding("UTF-8");
          String login = request.getParameter("login");
          String pass = request.getParameter("pass");
          RegistrationHelper registrationHelper = new RegistrationHelper();
          registrationHelper.setLogin(login);
  
          boolean isError = false;
          if (login == null || login.trim().equals("")) {
              String loginMessage = "It's empy";
              registrationHelper.setLoginMessage(loginMessage);
              isError = true;
          }
          if (pass == null || pass.trim().equals("")) {
              String passMessage = "It's empty.";
              registrationHelper.setPassMessage(passMessage);
              isError = true;
          }
          if(!isError) {
  
  
  
              UsersDAO dao = (UsersDAO) request.getServletContext().getAttribute("usersDAO");
              if(dao.checkIfLoginExists(login)) {
                registrationHelper.setLoginMessage("User with this name is already registered");
              } else {
                  dao.createUser(new User(login, Encryption.md5(pass)));
                  registrationHelper.setSuccess("Succesfully registered");
              }
          }
          request.setAttribute("registrationHelper", registrationHelper);
          RequestDispatcher dis = request.getRequestDispatcher("/");
          dis.forward(request, response);
      }
  }
  </code></pre>
  
  <p>And my register.jsp</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="./register" method="POST"&gt;
    Podaj login: &lt;input name="login" type="text" value="${registrationHelper.login}"  size="20"/&gt; ${registrationHelper.loginMessage} &lt;br/&gt;
    Podaj hasło: &lt;input name="pass" type="password" size="20"/&gt;${registrationHelper.passMessage}&lt;br/&gt;
    &lt;input type="submit" value="Register"/&gt;
    &lt;br&gt;${registrationHelper.success}
  &lt;/form&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So , if I get to registration page using this link </p>
  
  <pre><code>&lt;a href="register.jsp"&gt;Reg&lt;/a&gt;&lt;br/&gt;
  </code></pre>
  
  <p>It's all good and I have my registration form because doPost is used.</p>
  
  <p>But , if I try </p>
  
  <pre><code> &lt;a href="/register"&gt;Reg&lt;/a&gt;&lt;br/&gt;
  </code></pre>
  
  <p>I have nothing because doGet is used and no difference what I will write in doGet nothing changes and registration form doesn't appear.</p>
  
  <p>Thus , my question is , what should I wrire in doGet to have my registration form ?</p>