File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Accessing String Array with struts tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Accessing String Array with struts tags" Watch "Accessing String Array with struts tags" New topic

Accessing String Array with struts tags

bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95

What I want to do appears to be quite simple, but it is not working out that way.

I'm using Struts 1 and have a restriction to not use any JSTL or EL...only struts tags (it's a long story).

Short version:
I have an String array in the request with only one value: (stringArray = [oneValue])
And I want to display this "oneValue" on the page.

More details:
In actuality I'm passing an html:hidden value from the previous page which is coming over as a single object in a String array. I need to access this hidden value on the next page.

Thanks for your help!

"...and the Truth will set you free."
Jaimesh M Ponkia

Joined: Nov 24, 2010
Posts: 21
Try using logic iterator to iterate through the array and then bean write to print the value of the element.

Something like this should work:
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hmm...good idea. I actually thought that was going to work, but it didn't.

I do have a getter/setter in my form as well, just so everyone knows.

The interesting thing is that if I do this I receive the expected "oneValue":

So I know that the information is there.

Any other ideas?
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hello all.

Looks like the answer is found with this bean:parameter tag:

Alternatively, I could check for the variable's existence using a present tag with the parameter attribute:

I hope this helps someone else out in the future when dealing with request parameters and/or hidden form fields in struts...
satya pksh

Joined: Jan 17, 2010
Posts: 8
Use session or request either one set the value and get where ever you want...

Get wherever you want in jsp

I agree. Here's the link:
subject: Accessing String Array with struts tags
Similar Threads
Sending value from popup to parent window
Vector Values
String to byte[] Help needed- Urgent
Nested loops
assigning one primitve variable to another primitive variable..