This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Display Array data in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Display Array data in JSP" Watch "Display Array data in JSP" New topic
Author

Display Array data in JSP

kapil pat
Greenhorn

Joined: Jul 21, 2006
Posts: 3
Hello,

I have a property in the ActionForm of type array. I need to display that on the JSP tabele.

Below is the code snippet.

I am not able to iterate to the Array and display it on the JSP. I tried hardcoding the arrayindex like addressId[0] and it displays proper data.

Please suggest a way out..

Action Form
public class CustomerForm extends ValidatorForm {

String customerId = null;
String[] addressId = null;
String[] addressName = null;

}


JSP Page
<html:form action="customer" name="CustomerForm" type="test.CustomerForm">
<html:text name="customerData" property="customerId" />
<tabl>
<tr><td>Address ID </td><td>Address Name </td>
</tr>
<tr>
<td><html:text name="customerData" property="addressId"/></td>
<td><html:text name="customerData" property="addressName"/></td>
</tr>
</tabl>
</html:form>



Thanks in advance,
Kapil
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Kapil please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.

Where are you iterating over the arrays?? You are just displaying the array in text fields. Look at the logic:iterate tag...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
kapil pat
Greenhorn

Joined: Jul 21, 2006
Posts: 3
Thanks Ankit,

I did try logic:iterate but was not able to achieve it. Can you please help me in writing that part of code ?

My CustomerForm is available in the custBO session variable. And I have to create as many rows as the size of addressId Array.

Thanks,
Kapil
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Sorry but I'm not good at struts 1.x, someone else would be able to help you. You can show us the logic:iterate code that you tried which might make it easier to know the mistake that you did. This example might also be useful...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Display Array data in JSP
 
Similar Threads
blank page returned from validate
Module 'null' not found
Struts making me nuts :)
Struts Validation Empty alert Box
Can't get parameter in struts when using input type="file"...?