This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Logic iterate

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put my key and value pair in a Hashtable in session.How to get the key and vlaue seperetely in JSP.My code is

<logic resent name="category">
<logic:iterate id="id1" name="category" scope="session">

<html-el ption value="${id1}"><bean:write name="id1" property="value" /></html-el ption>

</logic:iterate>
</logic resent>

Is it right or wrong please tell me?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever you iterate over an implemnentation of java.util.Map, you get an object of type Map.Entry which has a key property and a value property. Knowing this, if you have a Map stored in session scope, you can create a list of options like this:

<html:optionsCollection name="category" value="key" label="value" />
[ January 08, 2007: Message edited by: Merrill Higginson ]
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a ton.If I want to use bean:write can i use like this

<select name="sel">

<logic:iterate id="match" name="hs">
<option name="uid" value=<bean:write name="match" property="key"/>>
<bean:write name="match" property="value"/>
</option>
</logic:iterate>

</select>
But this line value=<bean:write name="match" property="key"/>> is not a valid line in JSP.How can i do this?Pliz help.Thanks in advance
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ingoba,

I notice a lot of your posts get posted two or three times. I can understand that happening when the system is slow, but did you know you can delete the extra post if that happens? Just click on the icon that looks like a pencil and piece of paper to edit the post. On the page that follows, ceck the "delete" checkbox and click the "edit post" button. That will get rid of the extra post.

Now, in answer to your question:

Just put the <bean:write /> in single quotes like this:
<option name="uid" value='<bean:write name="match" property="key"/>'>
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill for your kind information.

I am using html ption I put

<html:text property="name" value='<bean:write name="match" property="key"/>'/>

But its printing <bean:write name="match" property="key"/> in the text box.

Pliz help.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic