File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt using E.L with HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt using E.L with HashMap" Watch "Doubt using E.L with HashMap" New topic
Author

Doubt using E.L with HashMap

Aryaraju Kumar
Greenhorn

Joined: Jan 31, 2008
Posts: 6
I appologize if iam posting this message in the wrong section since iam new to the forum iam not sure where this goes.And i want to know how to use Expression Language with a HashMap that is if iam having a DTO in the Value of the Hashmap how can i use E.L to access the DTO in the JSP page it would be of great help for me Thank you in advance.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Once you bind your map to one of the scoped objects, you can access its entries with either the dot syntax or associative array syntax.


You should also read up on JSTL which can be used, among other things, to iterate over maps, arrays, lists, etc...


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Aryaraju Kumar
Greenhorn

Joined: Jan 31, 2008
Posts: 6
Yeah Thanks man But i was looking for more specific answer i could use
something like
<c:forEach item="${rancher}" var="items">
<c:if test="${firstname==items.key}">
<c ut value="${items.value.firstname}"/>
<c ut value="${items.value.lastname}"/>
<c ut value="${items.value.salary}"/>
</c:if>
</c:forEach>

where firstname is scoped variable and the value is a DTO. I got the answer after i posted my question but thought it would be of future help
[ February 01, 2008: Message edited by: Arvind Kovuri ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

But i was looking for more specific answer

You could try to ask more specific question next time, like you'd like to know how to iterate through a Map


[My Blog]
All roads lead to JavaRanch
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Another JR tip:
At the bottom left of the edit screen is a checkbox for disabling those annoying smilies. It's a good idea to check that when entering JSTL code.

You did ask about EL, not JSTL.
They're different technologies. They go well together but their names are not interchangeable.
Are you confused about which is which?
[ February 02, 2008: Message edited by: Ben Souther ]
Aryaraju Kumar
Greenhorn

Joined: Jan 31, 2008
Posts: 6
Some Ssosssss wrote:Yeah Thanks man But i was looking for more specific answer i could use
something like
<c:forEach item="${rancher}" var="items">
<c:if test="${firstname==items.key}">
<c ut value="${items.value.firstname}"/>
<c ut value="${items.value.lastname}"/>
<c ut value="${items.value.salary}"/>
</c:if>
</c:forEach>

where firstname is scoped variable and the value is a DTO. I got the answer after i posted my question but thought it would be of future help
[ February 01, 2008: Message edited by: ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt using E.L with HashMap