| Author |
Issue with respect to String Array in Struts
|
Deepak Lal
Ranch Hand
Joined: Jul 01, 2008
Posts: 507
|
|
Hi Ranchers,
We are facing an issue as shown below.
Java code as shown below ::
When I tokenize the Strings I get 3 independent strings.which I need to display in the jsp page using logic:iterate one below the other how do I do that
In jsp output should be
Mumbai
Calcutta
Bangalore
Could you please help me with the code in JSP and how to set the countries in Java.(Action class)...
|
When The Going Gets Tougher,The Tougher gets Going
|
 |
Siva Masilamani
Ranch Hand
Joined: Sep 19, 2008
Posts: 377
|
|
set the String array in the request or session attribute and then use it in the jsp.
e.g. request.setAttribute("countryList",countries) in the action class
then in the jsp
or if you have array property int he form then set the country array inthe form property then use it in the jsp as below
|
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
|
 |
Deepak Lal
Ranch Hand
Joined: Jul 01, 2008
Posts: 507
|
|
or if you have array property in the form then set the country array in the form property then use it in the jsp as below
Hi Siva,
what changes do i need to make in in my form and in action class and jsp...could you help me out with that for the above code to work in jsp.
Thanks and Regards
Deepak Lal
|
 |
Siva Masilamani
Ranch Hand
Joined: Sep 19, 2008
Posts: 377
|
|
Let say this is the ActionForm
Then in the action class
In struts-config.xml,you might have something like this
the name in the iterate tag should match the name you defined inthe form-beans in struts-config.xml
In jsp
Additionally you may add logivc:prsent tag to check if the array is not empty before using iterate tag.i.e put the logic:iterate tag inside logic:present tag.
|
 |
Deepak Lal
Ranch Hand
Joined: Jul 01, 2008
Posts: 507
|
|
Hi Siva,
Thanks for the inputs.Let me check and get back to you in case i face any issues..
Thanks and Regards
Deepak Lal
|
 |
 |
|
|
subject: Issue with respect to String Array in Struts
|
|
|