dcsimg
<jsp:usebean> scope problems.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Archie_Marsden
Posted On:   Thursday, October 18, 2001 03:37 PM

I am attempting to use the action to use a bean for storing form input from multiple screens. I get inconsistent results. At least as far as my understanding is based from reading JavaServer Pages by Hans Bergsten (great book btw) I set up a practice jsp page that contains an input form. My useBean looks as follows: Then I call a jsp page that uses the action to display the values I entered. Unless my second page has the exact same useBean tag as above, only minus the scope attribute I get nothing back. If I add the scope attribute to the second page I get no result. If I remove the setProperty action from the second page I get no result.    More>>

I am attempting to use the action to use a bean for storing form input from multiple screens.
I get inconsistent results. At least as far as my understanding is based from reading JavaServer Pages by Hans
Bergsten (great book btw)

I set up a practice jsp page that contains an input form. My useBean looks as follows:





Then I call a jsp page that uses the action to display the values I entered.


Unless my second page has the exact same useBean tag as above, only minus the scope attribute

I get nothing back. If I add the scope attribute to the second page I get no result.

If I remove the setProperty action from the second page I get no result.


I have two questions. Should all useBean actions display the scope attribute even if you're only

reading from the bean?


Shouldn't I be able to read a bean without the setProperty action?

Thanks,


Archie (archiem@crengland.com)

   <<Less

Re: &lt;jsp:usebean&gt; scope problems.

Posted By:   Dave_McDonnell  
Posted On:   Thursday, October 18, 2001 05:03 PM

Yes, you must specify the scope for the bean in each jsp:useBean tag.


Yes, you should be able to read the bean without having to call setProperty, it will just have the default values for properties (ie null for objects, zero for integers, etc).


I'd check that you are setting the id attribute correctly. Both useBean tags must use the same id and scope values.


If that still doesn't work, try printing the output from session.getAttribute("beanName"). This should return the instance of your bean (at least in Jakarta Tomcat it will).
About | Sitemap | Contact