This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Loop in JSP with Struts  RSS feed

 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to Java. I'm creating a JSP page and uses struts as framework. I have the following code:


<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Companies with balance below Php 1,000:</TITLE>
</head>
<body>

 
<table border="0" >
<tr>
<td ><strong>Companies with Balance Below Php 1,000</strong>
</td>
</tr>
<tr></tr>
</table>

 
<table border="0" >
<tr >
<td td>Company</td>
<td td>Credits</td>
</tr>
<tr >
<td ><s:property value="orgList.get(0).getName()"/></td>
<td ><s:property value="orgList.get(0).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(1).getName()"/></td>
<td ><s:property value="orgList.get(1).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(2).getName()"/></td>
<td ><s:property value="orgList.get(2).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(3).getName()"/></td>
<td ><s:property value="orgList.get(3).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(4).getName()"/></td>
<td ><s:property value="orgList.get(4).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(5).getName()"/></td>
<td ><s:property value="orgList.get(5).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(6).getName()"/></td>
<td ><s:property value="orgList.get(6).getCredits()"/></td>
</tr>
<tr >
<td ><s:property value="orgList.get(7).getName()"/></td>
<td ><s:property value="orgList.get(7).getCredits()"/></td>
</tr>
</table>
</body>
</html>

How do I display the data without indicating the specific index since I don't know the size of my list? How do I use loop in jsp with struts as framework?

Hope you can help me.

Thanks in advance.

--Shyne

 
Marshal
Posts: 67163
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the struts iterator tag to iterate and conditional statments e.g.



Keep in mind you must have getter and setter methods for fields to be accessible by jsp's through your action class.

Hope this helps.
 
vern diok
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! It worked.. =)
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm Having a form Contains User-Info like name, age, address, country, zip, gender etc., in JSP(Using struts-2 and ajax tags). In same JSP page, I've HTML-Table contains these User-Info as headers. When the user clicks on submit button, All the data, what he entered in the form should populate on the Html table in the first row(always) and when he clicks on particular row in the table, the information re-populate on the form. The HTML-table contains maximum of 5 rows. If he entered sixth row, then pagination required. I want to do this in struts 2 - ajax. I'm new to Ajax. Can any one tell me how to do this. Please post the code if possible.

Thanks:
Ramakrishna
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!