Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form Bean scope problem

 
Java Buzz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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?

Regards,
Hari
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.

bear
JavaRanch Sheriff
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic