title: java.lang.NumberFormatException: For input string: "" - When I try to parse empty string as integer
body: <p>I wanna make a servlet where you write your name, surname, email address and you have to enter the correct sum of two numbers.</p>
  <p>I've got one problem. When I don't enter anything in this &quot;captcha&quot;, it gives me HTTP Status 500, Message: HTTP Status 500</p>
  <p>Exception:</p>
  <pre><code>java.lang.NumberFormatException: For input string: &quot;&quot;
      java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
      java.base/java.lang.Integer.parseInt(Integer.java:662)
      java.base/java.lang.Integer.parseInt(Integer.java:770)
      pl.coderslab.Sess05.doPost(Sess05.java:16)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  </code></pre>
  <p>I'd like it to return to the form so you have to type the captcha (I'm not checking the other fields, don't pay attention to it).</p>
  <p>Here's my code:</p>
  <pre><code>@WebServlet(&quot;/Sess05&quot;)
  public class Sess05 extends HttpServlet {
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          HttpSession sess = request.getSession();
          int userSum = Integer.parseInt(request.getParameter(&quot;captchaInput&quot;));   //Here's 16 line
          int correctSum = (int) sess.getAttribute(&quot;captcha&quot;);
          if (userSum != correctSum || request.getParameter(&quot;captchaInput&quot;).equals(&quot;&quot;)) {
              Random randGenerator = new Random();
              int firstRand = randGenerator.nextInt(101);
              int secRand = randGenerator.nextInt(101);
              int sum = firstRand + secRand;
              sess.setAttribute(&quot;captcha&quot;, sum);
  
              response.getWriter().append(&quot;&lt;form action='#' method='post'&gt;&quot;);
              response.getWriter().append(&quot;&lt;label&gt;Name: &lt;input type='text' name='name'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
              response.getWriter().append(&quot;&lt;label&gt;Surname: &lt;input type='text' name='surname'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
              response.getWriter().append(&quot;&lt;label&gt;Email: &lt;input type='email' name='email'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
              response.getWriter().append(&quot;&lt;label&gt;Enter the sum &quot; + firstRand + &quot; + &quot; + secRand + &quot;&lt;input type='number' name='captchaInput'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
              response.getWriter().append(&quot;&lt;input type='submit' value='Submit'&gt;&quot;);
              response.getWriter().append(&quot;&lt;/form&gt;&quot;);
              response.getWriter().append(&quot;Enter the correct sum!&quot;);
          } else {
              response.getWriter().append(&quot;Sum is correct!&quot;);
          }
      }
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          Random randGenerator = new Random();
          int firstRand = randGenerator.nextInt(101);
          int secRand = randGenerator.nextInt(101);
          int sum = firstRand + secRand;
          HttpSession sess = request.getSession();
          sess.setAttribute(&quot;captcha&quot;, sum);
          
          response.getWriter().append(&quot;&lt;form action='#' method='post'&gt;&quot;);
          response.getWriter().append(&quot;&lt;label&gt;Name: &lt;input type='text' name='name'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
          response.getWriter().append(&quot;&lt;label&gt;Surname: &lt;input type='text' name='surname'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
          response.getWriter().append(&quot;&lt;label&gt;Email: &lt;input type='email' name='email'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
          response.getWriter().append(&quot;&lt;label&gt;Enter the sum &quot; + firstRand + &quot; + &quot; + secRand + &quot;&lt;input type='number' name='captchaInput'&gt;&lt;/label&gt;&lt;br&gt;&quot;);
          response.getWriter().append(&quot;&lt;input type='submit' value='Submit'&gt;&quot;);
          response.getWriter().append(&quot;&lt;/form&gt;&quot;);
      }
  }
  </code></pre>