• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot find bean in any scope

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been trying to debug this application for 2 days now..
I am unable to understand what is wrong wth the code..
Please someone help me out...

I keep on getting this message as the Error 500 and I dont understand what it means while


this is the web.xml file--


Now the welcome.jsp is shown as this file --


The struts-config.xml has the action-mapping. Please consider the action-mapping for the enterDetails since the previous action mapping works fine.
The form-bean UserDetailsForm is also included later in this section


The code for the form-bean is as follows-


The countryData is another set of class which is as follows-


The action-class is as shown--






 
Kalith Aazad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I fail to understand here is that what should the optionsCollection property have?
the name?
the property that points to the list?
the name that points to the CountryData ??
I am really confused when it comes to this..
Please help me out..Thanks..
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you accessing welcome.jsp directly (younare using it as a welcome file) or through the action?
 
Kalith Aazad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear David,
I am calling the welcome.jsp file using the welcome-file-list..I am not directly calling it. When I run the application , it directs the control to welcome.jsp.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. So, the action isn't being run, right?
 
Kalith Aazad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the formbean is not being populated.
What i see is..
first on loading web.xml -> struts-config.xml -> welcome.jsp -> It is stuck..
If that is resolved, then the action will be loaded right and the bean be populated right???
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're calling the JSP directly--Struts isn't involved at all.
 
Kalith Aazad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So how do I go about calling the action?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You either configure the container to allow the use of an action as a welcome file (I don't remember how), or meta refresh to the action from a welcome page.
 
Kalith Aazad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear David,
Thank you . Will let you know if it worked .
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem!
 
Kalith Aazad
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so the course of action would be to call a test.jsp page from welcome-file list which redirects to the Action mapping.
The action class then calls the populate method and populates the formbean
which then after wards delegates the control to the welcome.jsp which displays the select options tag?
would that work?
 
Kalith Aazad
Greenhorn
Posts: 24
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally resolved it--

Here is the solution--
The struts-config.xml file--


The Action-form was created using SelectedItem as one more property for using it in the jsp file.
The Collections element was induced in the request object as CountryList.

The Action-Form



The Action - Class



The show-Details.jsp file--


What I observed was this--
For this to work in the form-bean if you have a country-list
countryList.add(new CountryData("1", "USA"));
countryList.add(new CountryData("2", "Canada"));
countryList.add(new CountryData("3", "Mexico"));
request.setAttribute("countryListAttribute",countryList);
Now, since the attribute in the request is set to countryListAttribute,
At the JSP side, for the html:select code,
<html:form action="/login">
<html:select name="UserDetailsForm" property="selectedItem">
<!-- property refers to the name of the request parameter in the form -->
<html:optionsCollection name="countryListAttribute" />
<!-- label="countryName" value="countryId" -->
</html:select>
<html:submit/>
</html:form>
Here , the action pertains to any action that will get executed once the submit is clicked.
The property=”selectedItem refers to a string property in the form “UserDetailsForm ” which has been mapped in the struts-config.xml as a form-bean mapping.The name of the form-bean is “UserDetailsForm”. Now, with the name=”countryListAttribute” , it is taken from the request scope. The request scope is present in the action mapping as described as under.
Thus an important part to be noted is that in html:select , the property=”selectedItem” should be a string in the form-bean.
If you do not have getlabel() and getValue() to the associated form-bean then, by default, if you do not put label=”countryName” and value=”countryID” , it searches for the implementation of the getLabel() and getValue() inside the form-bean.




reply
    Bookmark Topic Watch Topic
  • New Topic