| 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: 14685
|
|
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: ]
|
 |
 |
|
|
subject: Doubt using E.L with HashMap
|
|
|