aspose file tools*
The moose likes JSP and the fly likes jsp:useBean and TomCat's Introspection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:useBean and TomCat Watch "jsp:useBean and TomCat New topic
Author

jsp:useBean and TomCat's Introspection

Xon Bhuyan
Greenhorn

Joined: Sep 24, 2003
Posts: 11
Hi,
In my JSP view component I am setting a Bean's property like this:
<jsp:useBean id="xxxDetails" class="fun.moreFun.xxxDetails" scope="request"/>
<jsp:setProperty name="xxxDetails" property="*">
First of all I am not able to find the xxxDetails instance in my controller. If I set the scope as session I get the xxxDetails instance.
Secondly, even if I get the instance (scope="session") the properties are null! Meaning, something is going worng at property="*". I have set the field names and the property names as same.
Thirdly, if I set the properties using field names like:
<jsp:useBean id="xxxDetails" class="fun.moreFun.xxxDetails" scope="request"/>
<jsp:setProperty name="xxxDetails" property="yyy" value="yyy">
It gives introspection error as the yyy propery is of int type. As far as I know while introspection values are converted atomaticaly to the required datatypes using (Class).valueOf(), then it should work.
Please tell me where I am making the mistakes.


Xon Bhuyan
Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
I must admit I'm a bit confused. You're talking about your controller. Do you use a servlet as controller or are you handling everything with JSP's.
Both methods are possible, but I would prefer to work with JSP's for the view, java beans for the model and servlets as controller.
ABout the session and request scope :if you're using a java bean with request scope, then this bean will be deleted as soon as the user is rquesting another page. With a session, you will have a bean as long as the client session exists, not matter how many pages the user will request.
Normally, I never work with setProperty and getProperty (I prefer working with servlets and DAO's who make the java beans and hand them over to the JSP's).
But if I'm not mistaken, when you write :
<jsp:useBean id="xxxDetails" class="fun.moreFun.xxxDetails" scope="request"/><jsp:setProperty name="xxxDetails" property="*">
You are making a new Java bean. SO the content of all the variables depend on how you made the constructor. In that case, it's normal that your variables don't have any value, if you didn't define a default value in your constructor.
tom phan
Greenhorn

Joined: Jun 08, 2001
Posts: 5
Actually, I have a similar problem. Here's my setting:
- A servlet controller as entry point, instanciates a bean and puts it in the session. Then a dispatcher forwards to a JSP page
- The JSP page sets the property value in the bean and goes back to the controller.
- The controller, which should display the bean property value, actually outputs null. I would be ready to think the bean property wasn't set correctly, but if I forward to a second JSP page to display the bean value, then it display the value correctly.
I'm really puzzled, so if anyone has an input on that, I would appreciate greatly.
Thanks,
Tom
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean and TomCat's Introspection