jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Form Bean scope problem   Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form Bean scope problem   " Watch "Form Bean scope problem   " New topic

Form Bean scope problem

Java Buzz

Joined: Mar 11, 2005
Posts: 10
I am facing a weird problem with struts. I have a link on the first page of my application, clicking on which I invoke a action class. It connects to database, pulls out data populates a form bean and forwards to a jsp.

In the jsp, I am accessing the properties of the form bean and I am displaying. But when I run the same, all the values displayed are empty. However logs at action classes convey that data was fetched from database and is set into the form bean. I have set the scope of the bean to be request.

Any guess what could be the problem?

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
This question is better suited for Struts forum.

In the jsp are you getting the bean or you are getting the bean without the values?
Note : If the bean doesn't not exits , then its creates one.What I guess is you are setting the bean in one scope and then trying to retrieve it back from some other scope , that might be the reason that you are getting the bean and not the values.

You can even look at the serverts which is being created out of your jsp for seeing as what actually is going.

Rahul Bhattacharjee
LinkedIn - Blog
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

"Java Buzz", you have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Be aware that accounts with invalid display names are removed.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Mr. Buzz:

Are you instantiating a new instance of your Action Form in your action code or are you using the form passed in as a parameter to the execute method? If you are instantiating a new form, then you have to save it as a request attribute with the same name defined in struts-config. A better option might be to change your action mapping and use the form passed in.

- Brent
I agree. Here's the link: http://aspose.com/file-tools
subject: Form Bean scope problem
It's not a secret anymore!