Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

<c:forEach> tag

843836Feb 25 2004 — edited Feb 25 2004
Hi,
I'm trying to use the forEach tag in the jstl in order to display the contents of an Hashtable. The table is written in the session and arrives populated with the results of a SELECT query.
The elements of the table are instances of a class of mine, and I'd like to display some of the fields (all accessible by getters and setters) of this class.
The fact is that if I try to write the elements of the table, I obviously get the class of the elements followed by their ID number (like Object@64383265), but if I try to access a field, I get nothing.

Here is the code reading the elements:
risposta = Hashtable in the session, contains dap.obj.Notizia objects

<jsp:useBean id="notizia" scope="page" class="dap.obj.Notizia" />
<c:forEach var="notizia" items="${risposta}">
<c:out value="${notizia}" />
</c:forEach>

And if I try to replace the line of output with:
<c:out value="${notizia.ID}" />

I obtain an error saying:

(...) Unable to find a value for "ID" in object of class "java.util.Hashtable$Entry" using operator "." (null)

If I use
<c:out value="${notizia.[ID]}" />

no errors and nothing appears..

Do I need to know something about the cast inside the tags of jstl or am I trying to do something wrong?
I admit that these are my first days with jstl, but I've searched among some books with no results. Thanks in advantage for your jelp
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 24 2004
Added on Feb 25 2004
2 comments
85 views