A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Frameworks
»
Struts
Author
List from Action to JSP in Struts 1
Kartik Talasu
Ranch Hand
Joined: Aug 21, 2009
Posts: 98
posted
Oct 05, 2009 05:41:00
0
Hello All,
Am having a
JSP
where I was suppose to show a
dropdown box
, where the values of dropdown are in a
list
which is in
request attribute
.
So in JSP I had written a scriplet and got the list, and working fine.
<% ArrayList data =new ArrayList(); data=(ArrayList)request.getAttribute("mainCombo"); %> <select name="mainCombo" id="mainCombo" onchange="populateFromDiscreteList(this)"> <% for(int i=0;i<data.size();i++) { %> <option value="<%=data.get(i)%>"><%=data.get(i)%></option> <% } %> </select>
But I heard the getting the results from scriplet is not a good practise, so is there any other way to get them?
NOTE: Am using Struts 1
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
I like...
posted
Oct 05, 2009 06:19:50
0
Use the
<html:select>
and
<html:options>
or
<html:optionsCollection>
tags.
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: List from Action to JSP in Struts 1
Similar Threads
Retain option selected value on submit
Using AJAX in Struts.... need steps to Implement..
dropdown from database
ArrayList gets duplicate values in JSP
problem with javascript
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter