File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Displaying Values in JSP Page using Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "Displaying Values in JSP Page using Struts" Watch "Displaying Values in JSP Page using Struts" New topic
Author

Displaying Values in JSP Page using Struts

Gopinath Reddy
Greenhorn

Joined: Feb 26, 2004
Posts: 15
Hi all

I am new to struts I am getting problem while displaying the values in JSP page while using HashMap and ArrayList

/*This is the code for Array List*/

ArrayList al = new ArrayList();
while(rs.next()){
al.add(rs.getString(1));
}

I want to display the contents of al object in JSP Page using Stuts <logic:iterate> tag . Thing is this al object is having more that one value
so with out struts we can use for loops and Enumerations to display the value. But pls help me how to display this using struts logic:iterate tag.

Pls give me sample code.

/*This is my hash map code*/

HashMap hm = new HashMap();
while(rs.next()){
hm.put("name",rs.getString(1));
hm.put("age",rs.getString(2));
hm.put("sex",rs.getString(3));
}

The above is my HashMap code i have diplay this value in JSP using logic:iterate tag.


Pls Provide me code for this.

regards
Gopinath
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
These links should get you started.
<logic:iterate>
Indexed and Mapped Properties

Sheldon
Michael Enzo
Greenhorn

Joined: Sep 13, 2004
Posts: 4
One possibility..

First make sure you have the hashmap is in context (use a tag to put it into page context), or just put it in the session if it will be used over several pages..
Let's assume it's in page context, with the name 'contextHash':

<logic:iterate id="dbHash" name="contextHash" type="java.util.HashMap">
Name:<bean:write name="dbhash" property="name" />
Age:<bean:write name="dbhash" property="age" />
.
.
.
</logic:iterate>


Didn't test it.. hopefully it'll help you out.

There's an example of this in the docs.. here
http://struts.apache.org/userGuide/struts-logic.html#iterate


Fear the Qubit
 
 
subject: Displaying Values in JSP Page using Struts
 
Threads others viewed
problem in encoding in the jsp page.
display a arraylist value in JSP using JSTL
Displaying values in JSP using Struts Tag
Not able to iterate through a bean property of type Array List
Using of nested Datatables
developer file tools