File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 6529

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
I agree. Here's the link:
subject: struts html:options collection
It's not a secret anymore!