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:FormBean issue with html:select tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts:FormBean issue with html:select tag" Watch "Struts:FormBean issue with html:select tag" New topic

Struts:FormBean issue with html:select tag

Nicolas Flammel
Ranch Hand

Joined: May 05, 2004
Posts: 32
I have a JSP that has the following code:
<html:select name="formBean" property="textId">
<html: options
<html: options
I have the setters and getters for the bean attributes in the form bean that is defined in the struts-config.xml file as:
<form-bean name="formBean" type="com.xora.apps.messaging.presentation.form.MyForm
The collection WORDS is set in the request attribute and contains a List of values when the action form is called(ie when the form loads) to be populated in the options tag. But when the form loads the message:
500 Servlet Exception
javax.servlet.jsp.JspException: Cannot find bean under name formBean
is displayed even after manually creating the formBean instance in the ActionForm page as
MyForm formBean = new MyForm();
Any fix suggested would be greatly appreciated...
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

First off, I'm assuming that the form-bean tag is not left open like that in your struts-config. And the same with your htmlptions tags.
It's usually best practice to use the ActionForm associated with the jsp for retrieving values if they are to come from an ActionForm at all.
Simply creating the other form (which I assume to be another ActionForm) inside the ActionForm associated with your jsp does not do anything beneficial on its own. You also need to create a getter for it. Your app is looking for a getFormBean() method in the ActionForm.

A good workman is known by his tools.
I agree. Here's the link:
subject: Struts:FormBean issue with html:select tag
It's not a secret anymore!