my dog learned polymorphism
The moose likes Struts and the fly likes Problem with bean:define Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with bean:define" Watch "Problem with bean:define" New topic

Problem with bean:define

Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Hi Friends,
I am facing a strange problem . My form(bean) class has property whose type is long,but its getter method is returning String.In the JSP I am showing the value of that bean using

when I am running it is giving exception saying getter method of sessionTime is not found.
When I am changing the getter method to long it is running perfectly.
Does anybody has faced similer problem.I am using Tomcat 4.0.3 and struts1.1 .
Thanks in adv
[ April 28, 2005: Message edited by: Nataraj Ramesh ]
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
The tag <bean:define> is typically used to define scripting variables. My interpretation has always been that it should be used for run-time decisions, but I don't think this is spelled out anywhere. Most beans should be instantiated and placed into context (request, session, etc...) by an Action. If it is a form bean, it may be specified in the struts-config.xml, in which case the form bean will automatically be placed into context as appropriate. As a side note, form beans should only have properties which are String, booleans, other form beans, or Collections or arrays of Strings, booleans, and other form-beans.
As for your specific problem, does your bean have a method getSessionTime(), with the 'S' in "Session" capitalized? Assuming this is true, what happens if you change your internal representation of sessionTime from a long to a String?
[ January 19, 2003: Message edited by: Jason Menard ]
Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Same exception is given even if I capitalize the first character of property, but when I changed my JDK from 1.3 to 1.4.1 . it is working. Since we are not yet migrating to 1.4, I created some dummy getter methods which is returnning String and now it is working perfectly.
Is it problem of JDK 1.3 or something wrong with my code
Thanks in adv
I agree. Here's the link:
subject: Problem with bean:define
It's not a secret anymore!