Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing String Array with struts tags

 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

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!
 
Jaimesh M Ponkia
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use session or request either one set the value and get where ever you want...
Like


Get wherever you want in jsp

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic