title: Break out of a forEach loop in JSP/JSTL
body: <p>I have a collection of objects which have some properties. A property can only be of two types either <code>Type1</code> and <code>Type2</code>.</p>
  
  <p>All I want to do is to check if an object has a property of <code>Type1</code>.</p>
  
  <p>I'm using the following code for that:</p>
  
  <pre><code>&lt;c:set var="properties" value="${obj.getProperties()}"/&gt;
  &lt;c:set var="hasPropertyOfType1" value="false"/&gt;
  &lt;c:forEach var="i" begin="0" end="${fn:length(properties) - 1}"&gt;
      &lt;c:if test="${properties.get(i).isOfType1() eq true}"&gt;
          &lt;c:set var="hasPropertyOfType1" value="true"/&gt;
      &lt;/c:if&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>The above code achieves what I want but is highly inefficient because the number of properties an object may have is quiet high.</p>
  
  <p>So my question is how to break out of the forEach loop once I set the <code>hasPropertyOfType1</code> equal to <code>true</code>.</p>
  
  <p>Some approaches I have in mind, which I don't know how to implement (or that they're even possible) are:</p>
  
  <p>1: Add a condition to the forEach loop which will stop the loop.<br />
  2: Increment the index value inside the loop to a value greater than <code>fn:length(properties)</code>.<br />
  3: Use the break statement if possible.</p>
  
  <p>I have searched a lot but still haven't been able to figure this out. Thanks in advance.</p>