Check if a Integer is empty
<p>I want to check if a <code>Integer</code> value is empty.
The value for <code>Integer</code> is completed in a form. Here is my code.</p>

<p>Here the value is introduced:</p>

<pre><code>&lt;input name="varsta" placeHolder="Varsta:" type="text" data-constraints='@NotEmpty @Required @AlphaSpecial'&gt; &lt;br/&gt;&lt;br/&gt;
</code></pre>

<p>Now I want to check if there are data introduced or not.</p>

<pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

    Integer varsta = Integer.parseInt(request.getParameter("varsta"));
    request.getSession().setAttribute("varsta", varsta);

    try {
        DBConnection connection = new DBConnection();
        Connection con = connection.Connect();

        PreparedStatement ps = con.prepareStatement(
            "insert into user(Nume,Prenume,E_mail,Parola,Varsta,Sex,Greutate,Inaltime,Nivel_activitate,Calcul_calorii)" + 
            "values ('"+nume+"','"+prenume+"','"+email1+"','"+parola+"','"+varsta+"','"+sex+"','"+greutate+"','"+inaltime+"','"+activitate+"','"+calorii+"')"
        );

        if (varsta == null &amp;&amp; "".equals(varsta)) {
            String message = "Va rugam completati cu atentie TOATE campurile!";
            request.setAttribute("message", message);
            request.getRequestDispatcher("/inregistrare.jsp").forward(request, response);           
        } else {
           int i = ps.executeUpdate();

           if (i &gt; 0) {
              request.getRequestDispatcher("/preferinte.jsp").forward(request, response);
           }
        }
        ps.close();
        con.close();         
    } catch(Exception se) {
        se.printStackTrace();
    }
}       
</code></pre>

<p>is not working.</p>

<p>Could anyone help me?</p>