• 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 Scope Request

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is so stressful for having problems one after another. And I do not have the ability to see the causes of those problem on my own.

The error message that appears in the browser (runtime problem, not compilation problem) is:


'[ServletException in:/frame/content/content.jsp] Cannot find bean PageBeans in scope request'


The message is confusing because PageBeans (plural) is a Collection of PageBean (singular). Upon successful execution of a servlet, PageBeans (plural) is passed in a request scope to help creating a drop down menu in 'content.jsp'. And the 'content.jsp' with the drop-down menu (see the code below) is displayed successfully. PageBean is a regular JavaBean, which currently has only one property called 'name' (I keep it simple for testing purpose).

This problem occurred when I click on the Submit button of this form in the 'content.jsp'. Althouth PageBeans (plural) is used to create a drop-down menu in this form, PageBeans (plural) is irrelevant in the subsequest steps. Why do I get '[ServletException in:/frame/content/content.jsp] Cannot find bean PageBeans in scope request' by clicking on the Submit button of the form?

Partial content.jsp code:

Here is my action mapping for submitting the above form:

The "editTitleForm" is a form-bean in the <form-beans> element of the struts-config.xml file.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is that the submission is failing validation. If it fails validation then it is sent to the input forward, which is the same page... but no longer has the PageBeans in request.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, thank you for sheding light on the problem I have. My code had worked fine until form validation was added.

I was testing if validation worked. Therefore, I intentionally left all text fields blank, menu not selected, and submit the form. Apprarently, the control returned to the 'content.jsp' due to validation errors.

Q1. How come I do not see validation warning messages? I have prepared validation.xml and put it together with the validator-rules.xml in the AppName/WEB-INF directory. I have also prepared the warning messages in the AppName/WEB-INF/classes/resources/application.properties corresponding to the value of the 'key' attributes.

Q2. What should I do? My action servlet passes this Collection PageBeans in a request scope to create a drop-down menu in the 'content.jsp'. If validation errors occur and the control returns to the 'content.jsp', I have the error message 'cannot find bean PageBeans' in scope request'. How to handle this kind of situation?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) You would see the error messages if it were not for the exception being thrown.

2) You have 2 options. You can keep calling the db OR you can store the value in a scope greater than request. If it is a common list that does not change, application scope would be a GREAT place.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I invalidate the "application". I mean that if I have a session scope, I can code:

session.invalidate();

when session is no longer in use. How do I nullify the objects in an application scope and then invalidate the application?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know of only a few options on how to invalidate the application.
My favorite is:
getComputer().getPlug().pull();

The point of putting it in application is so that all users can access it. As long as the application is running, you only need one copy.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic