title: Retrieve values from Java.class List in JSP page
body: <p>I am new to java and JSP. I have found many examples of looping over a returned java class list in a jsp page but none have worked for my situation. The examples do not always show the @page and @taglib values so I have included them because I do not know if there is a specific order required for importing. </p>
  
  <p>I have the following jsp page.</p>
  
  <pre><code> &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
   &lt;%@page import="java.io.*,java.util.*,java.sql.*"%&gt;
   &lt;%@page import="javax.servlet.http.*,javax.servlet.*" %&gt;
   &lt;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
   &lt;%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%&gt;
  
   &lt;c:set var="cp" value="${pageContext.request.servletContext.contextPath}" scope="request" /&gt;
  
   &lt;html&gt;
        &lt;body&gt;
             &lt;% java.util.List x = new path.to.java.class.method(); %&gt;
             &lt;%=x %&gt;
  
             &lt;c:forEach items="${x}" var="element"&gt;
                  &lt;c:out value="${element.id}"/&gt;
             &lt;/c:forEach&gt;
        &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>The &lt;%=x %> displays comma seperated values like this, path.to.java.class@1234abcd, for the correct number of values returned from the database.  The forEach loop will not display anything.</p>
  
  <p>What am I missing?</p>