title: How to validate fields of an object in JSP?
body: <p>Following is a sample class:-</p>
  
  <pre><code>public class Response {
  
    private String hash;
    private Integer count;
    private Optional&lt;String&gt; name = Optional.empty();
  
    // getters and setters
  }
  </code></pre>
  
  <p>Now in the JSP file, I can access the fields, something like:-</p>
  
  <pre><code>&lt;c:forEach var="rr" items="${data}"&gt;
    ${rr.hash}
    ...
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>My question is, how will I come to know in the JSP file if the value for that field exists? There is a <code>name</code> field which is optional. If for an instance, I have not set it's value, then how can I know this is the JSP file?</p>