This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes Logic iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Logic iterate" Watch "Logic iterate" New topic
Author

Logic iterate

Ingoba Ningthoujam
Ranch Hand

Joined: Dec 04, 2006
Posts: 90
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?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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:

<htmlptionsCollection name="category" value="key" label="value" />
[ January 08, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Ingoba Ningthoujam
Ranch Hand

Joined: Dec 04, 2006
Posts: 90
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

Joined: Feb 15, 2005
Posts: 4864
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

Joined: Dec 04, 2006
Posts: 90
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logic iterate