jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes how to set  value in a map? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to set  value in a map?" Watch "how to set  value in a map?" New topic
Author

how to set value in a map?

Svetlana Koshkina
Ranch Hand

Joined: Jul 08, 2003
Posts: 108
I just started to learn JSPs and stuck on how to set values in a map.
Suppose i have the following:
<%Map map = new HashMap();
map.put("Mon", "Monday");
map.put("Tue", "Tuesday");
map.put("Wed", "Tuesday");
map.put("Thu", "Thursday");
map.put("Fri", "Friday");
map.put("Sat", "Saturday");
map.put("Sun", "Sunday");
%>//I can get value like this:
<%= ((Map)pageContext.findAttribute("map")).get("Wed") %>
//or like this <c ut value=" ${map.Wed}"/>
//this does not work:
<%-- <c:set value="Wednesday" target="map" property="${map.Wed}" /> --%>

I looked everywhere but it supposed to be so self-evident that details are found nowhere.
Please help me how to do it, because I'm stuck here. I'm dumb.
:-)
Sergiy Kamenyev
Greenhorn

Joined: Oct 03, 2003
Posts: 8
You can use:
<%map.put("Wed","WEDNESDAY");%>
It will replace previous value.


!
Svetlana Koshkina
Ranch Hand

Joined: Jul 08, 2003
Posts: 108
No no no, thanks.
I know how to program. Scriplets don't count. I want jstl way. :-)
???

Originally posted by Sergiy Kamenyev:
You can use:
<%map.put("Wed","WEDNESDAY");%>
It will replace previous value.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60756
    
  65

Welcome to the Ranch skaa!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Thanks!
bear
JSP Fourm Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Svetlana Koshkina
Ranch Hand

Joined: Jul 08, 2003
Posts: 108
It's my name: Svetlana
Koshkina is valid family name in Russian though assumed (if you want to see my true family name that is sort of complicated you can visit my web site).
Originally posted by Bear Bibeault:
Welcome to the Ranch skaa!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Thanks!
bear
JSP Fourm Bartender

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60756
    
  65

Svetlana, I like your name just fine. It's skaa's that that post was directed at.
bear
[ October 03, 2003: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set value in a map?
 
Similar Threads
How to Set HashMap in request attribute using JSTL Tag
How to set and get values from HashMap using JSTL
Setting attributes in Tag files
How can I Iterate a map
logic:iterate tag