File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes populating a dropdown list from db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "populating a dropdown list from db" Watch "populating a dropdown list from db" New topic

populating a dropdown list from db

Pritty GK

Joined: Jun 01, 2007
Posts: 1
Hi All,
I am trying to pupulate a dropdown list with values from db is struts.

I have my getters and setters in my UserForm
private List usertype = null;

public List getUsertype() {
return usertype;
public void setUsertype(List usertype) {
this.usertype = usertype;

UserForm userForm = (UserForm) form;
ReferenceService refService = ReferenceService.getInstance();
List userType = null;
userType = refService.getListRef(Constants.USER_TYPE);

jsp page

<html:select property="usertype" name="userForm">
<html ptions collection="usertype" property="refCode" Property="refDesc" />

I am getting this error :
- Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: No getter method for property: "userType" of bean: "userForm"
at org.apache.struts.taglib.TagUtils.lookup(
at org.apache.struts.taglib.logic.IterateTag.doStartTag(
at org.apache.jsp.jsps.MaintUser_jsp._jspService(org.apache.jsp.jsps.MaintUser_jsp:266)
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServletWrapper.service(
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$

really needing some help on this...
Paras Jain
Ranch Hand

Joined: Feb 26, 2005
Posts: 138

Rename the variable "usertype" to "userType" . notice the change in case.

Also I am not sure if there is any attribute by the name Property for tag html ptions. There is an attibute called "property" but attribute "Property" may not work.(again, notice the change in case)

Paras Jain
SCJP 5.0
I agree. Here's the link:
subject: populating a dropdown list from db
It's not a secret anymore!