• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set value in a map?

 
Svetlana Koshkina
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use:
<%map.put("Wed","WEDNESDAY");%>
It will replace previous value.
 
Svetlana Koshkina
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Svetlana Koshkina
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic