It's not a secret anymore!
The moose likes Struts and the fly likes dropdown problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dropdown problem" Watch "dropdown problem" New topic

dropdown problem

Vishal Maga

Joined: Nov 27, 2007
Posts: 11
I am not getting this logic iterate.Below is my code for that please help.
In My JSp i have
<td height="21" align="left" bgcolor="#F3F3F3" class="smallwhitetext"><strong class="bluetext">Domain Knowledge </strong></td>
<td> <html:select property="selectedDomain" name ="ExpSearchBean">
<html ptions Collection="DomainDropdownList" name ="ExpSearchBean" property="domain" value="doaminID" label="domainName" /></html:select></td>

In action:-
DropdownGetDAO dropdown = new DropdownGetDAO();
Collection details2 = dropdown.fetch();
request.setAttribute("domain", details2);

And in DAo:-

public Collection fetch() {
String INSERT = "SELECT * FROM tbl_domain";
System.out.println("Search Query:: " + INSERT);
Collection arr = new ArrayList();
PreparedStatement pStmt = null;

ResultSet rs;
String s = null;
Connection con = getConnection();
try {
pStmt = con.prepareStatement(INSERT);

rs = pStmt.executeQuery();
arr.add(new org.apache.struts.util.LabelValueBean(rs.getString("domainID"), rs.getString("domainName")));


} catch (Exception e) {

return arr;
Every time i m getting failed to get the collection.
Please help. Is my JSp code is correct.

Thanks in advance
Vishal Maga

Joined: Nov 27, 2007
Posts: 11
i did some following modification, but still not getting answer.

<html:select property="selectedDomain" styleClass="dropdown" size="1" >
<html ptions property="domain" />

public ArrayList getDomain() {
return domain;
public void setDomain(ArrayList domain) {

this.domain = domain;

public String getSelectedDomain() {
System.out.println("in get method"+selectedDomain);

return selectedDomain;

public void setSelectedDomain(String selectedDomain) {
System.out.println("in set method"+selectedDomain);
this.selectedDomain = selectedDomain;
public ActionForward loadData(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
DomainFormGetDAO dao1 = new DomainFormGetDAO();

ArrayList details = dao1.fetch();
ExpSearchBean dropdownForm =(ExpSearchBean) form;

request.setAttribute("domain", details);

return (mapping.findForward("success"));

<form-bean name="ExpSearchBean"
<form-property name="selectedDomain" type="java.lang.String"/>

<action path="/loadData" name="ExpSearchBean"
<forward name="success" path="/ExpSearchCandidate.jsp" />

On load the dropdown is still blank. Please let me know where i m doing wrong.

Thanks in advance
It is sorta covered in the JavaRanch Style Guide.
subject: dropdown problem
It's not a secret anymore!