Struts 1.1: Problems with logic:iterate tags and "Cannot find bean XXX under any scope"

While trying to use the in my application i ran into the error:

javax.servlet.jsp.JspException: Cannot find bean providerListData in any scope

trying to use a . This is a generic error message that the compiler throws to let you know something is wrong with either your data or your setup.
First make sure you have included the taglib necessary to interpret the logic:iterate tag ie adding the line:

''

to you JSP (Assuming you do have the struts.jar jar in your WEB-INF/lib folder and the TLD files in your WEB-INF folder ). If that still does not solve your problem, check the spelling of your bean name, believe it or not it might be as simple as a capitalization error. In my application i wrote my tag this way:

''

and i set the ProviderView collection in my Action class this way:

request.setAttribute("ProviderView", ps);

with ps being an array of Physician objects. If you have gone through all these steps and you still are getting the "cannot find bean" error, then your data must be the error, as it must contain null values. If your collection might contain null elements, make sure to use a tag. I added the line

''
''

...Rest of my display logic
...
''
''
''

The line checking for the existence of the collection element got rid of the error message. So always make sure you return data (in your collection) does not contain null elements and if it does, use the or tags to handle those cases and you should be fine. On a related not, i kept running into a

javax.servlet.jsp.JspException: No getter method available for property physicianId for bean under name org.apache.struts.taglib.html.BEAN

while trying to set up a radio input this way:

Even though my bean had the getPhysicianId() set up properly and spelled correctly because again spelling could be the issue. If you have a property called "myId", your getter method should be get M yId(). Since a spelling error was not the issue here, i looked closely at the attribute description on the Jakarta homepage and this line got my attention:

The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. (RT EXPR)

So the problem was that since i did not specify the name of the bean to use, it was using the default one (ActionForm) which of course did not have a getPhysicianId() method. By rewriting the code like this:

Specifying the name attribute was what it took to fix the problem for me!

HIH (Hope It Helps)!

Author image

About Abou Kone

You've successfully subscribed to SmartLogic Blog
Great! Next, complete checkout for full access to SmartLogic Blog
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.