help treating several input boxes as an array

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-03-31
I want to ask the user to input a maximum of 5 contract dates in jsp. Btw, im using struts.

As of now, my code is something like this:


<tr><html:text  property="date1"/></tr>
<tr><html:text  property="date2"/></tr>
<tr><html:text  property="date3"/></tr>
<tr><html:text  property="date4"/></tr>
<tr><html:text  property="date5"/></tr>

<action form>
public class contractForm extends ActionForm {
private String date1;
private String date2;
private String date3;
private String date4;
private String date5;

/* getter and setter for date1 to date5 */

<action servlet>
/* here I have a collection that checks if a date exists then adds it */

Its very tedious, is there a way to do something like

date[0]... date[4] in the <html:text>

then treat it as an array of String in action form?

how do I write the getter and setter in the action form? and how do I retrieve the data in the action servlet?

Can someone provide me with the code for this? Im confused. I'm thinking of using logic:iterate but im not even sure if this is the correct way to implement it.


Question by:delphiusr
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 92

Accepted Solution

objects earned 800 total points
ID: 8022560
try using the same property name for all fields.
And have a getter/setter that takes an array of strings.

Author Comment

ID: 8022979
Thanks! it worked nicely!
LVL 92

Expert Comment

ID: 8023010

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question