This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Struts and the fly likes struts  html:options collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts  html:options collection" Watch "struts  html:options collection" New topic

struts html:options collection

Abebe Belew

Joined: Jul 21, 2004
Posts: 19
I am trying to poptulate a drop down list by using html ption but I get this error message when I try to run the app. "Cannot find bean under name glu_bp' " any idea why?

jsp tag:
<html:select name="glucoseForm" property="glucose_bloodPressure">
<html ptions collection="glu_bp" property="id" labelProperty="description"/>

HttpSession session = request.getSession(true);
GlucoseForm glucoseForm = (GlucoseForm) form;

GluService service = new GluService();
Collection glu_bp = service.getGlu_bp();
session.setAttribute("glu_bp", glu_bp);
glucoseForm.setGlucose_bloodPressure("Glucose"); //to set the default value


public class Glucose_bloodPressureBean {

private int id;
private String description;

public Glucose_bloodPressureBean() {
public Glucose_bloodPressureBean( int id, String description ) { = id;
this.description = description;
public int getId() {
return id;
public void setId(int id) { = id;
public String getDescription() {
return description;
public void setDescription(String description) {
this.description = description;

import java.util.Collection;
import java.util.ArrayList;

public class GluService {

public Collection getGlu_bp() {
//call business layer to return Collection of Department beans
//since we aren't dealing with the model layer, we'll mimic it here
ArrayList list = new ArrayList(2);
list.add( new Glucose_bloodPressureBean( 0, "Glucose"));
list.add( new Glucose_bloodPressureBean( 1, "Blood Pressure"));

System.out.println(" this is the array list" + list);
return list;

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6264

What URL are you trying to bring up? You'll get the message if you try to go directly to the JSP without going through the Action first.

Junilu - [How to Ask Questions] [How to Answer Questions]
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
You need a bean efine on the collection bean, be sure to include it's type or your options property fields will not find the getter methods
It is sorta covered in the JavaRanch Style Guide.
subject: struts html:options collection
It's not a secret anymore!