• Post Reply Bookmark Topic Watch Topic
  • New Topic

Populating a Select List with an Array

 
Steve Dyke
Ranch Hand
Posts: 1717
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array assigned to a session attribute. In my HTML page I have a forEach tag using the session attribute. What do I need to do in the Option tag to get each item to display in the list?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve Dyke:
In my HTML page I have a forEach tag using the session attribute.

A JSP tag in an HTML file isn't going to do anything. You'll need to make the page a JSP.

I've moved this to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where's your code? This is a simple matter of constructing <option> elements from the list contents.
 
Steve Dyke
Ranch Hand
Posts: 1717
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I get error that itemName cannot be resolved.

[ January 21, 2008: Message edited by: Steve Dyke ]
[ January 21, 2008: Message edited by: Bear Bibeault ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you mixing scriptlets with JSTL tags?

Look up the "varStatus" attribute to the c:forEach tag.
It will give you both an index and a count property that can be used within each iteration.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'itemName' isn't a JSP variable.
Use EL to reference it.

${itemName}

Don't mix scriptlets with JSTL.
[ January 21, 2008: Message edited by: Ben Souther ]
 
Steve Dyke
Ranch Hand
Posts: 1717
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I got it functioning ok now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!