aspose file tools*
The moose likes JSP and the fly likes weird error when using a java bean with my jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "weird error when using a java bean with my jsp " Watch "weird error when using a java bean with my jsp " New topic
Author

weird error when using a java bean with my jsp

david eberhardt
Ranch Hand

Joined: Jul 02, 2002
Posts: 158
I have a web page that is asking the user to select from a choice of check boxes and sned it to a jsp (http://localhost:8080/card_trick_results.jsp) for processing.
the jsp page calls on a javabean (CardTotal.class) to process the logic:
here is some of the code from the top of the CardTotal.java file -

the problem:
When I execute the jps page, the server responds with an error:
org.apache.jasper.JasperException:
Can't find a method to write property 'card1' of
type 'int' in a bean of type 'CardTotal'

now, if I rewrite
public int getCard1 () {
return card1;
}

to
public int getcard1 () {
return card1;
}

and recompile this class, then the jsp page is able to process and return the correct page result.
If I shut down and reboot the computer and restart tomcat, I get the same sequence of problems again!
[b] anybody know what is happening?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

You didn't show how you are accessing the Card1 property from the JSP. From the error message, I'm assuming you are trying to set it from an int.
In which case:

is not a valid bean mutator signature.
Something along the lines of

should keep it happy.
hth,
bear
[ April 01, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
david eberhardt
Ranch Hand

Joined: Jul 02, 2002
Posts: 158
Originally posted by Bear Bibeault:
[QB]You didn't show how you are accessing the Card1 property from the JSP. From the error message, I'm assuming you are trying to set it from an int.

Bear,
my JSp page takes parameters from checkboxes in a form from a previous html page as follows:

here is the line where I get the totalCard value back to the JSP page:

and here is more of the "bean" I'm using:

[b]I never really use the getCard1() method, but if you look at my getCard1() method, you can see that I have changed it from the original.
This works now every time I reboot the computer.
The odd thing to me was that I could get it to work if I changed the case of the getCard1() to getcard1() and recompiled without rebooting BUT if I rebooted, then it would give me the error msg.
NOTED: Your criticism of my setTotalCard() method is noted and I will change those methods !!!
[ April 02, 2003: Message edited by: david eberhardt ]
david eberhardt
Ranch Hand

Joined: Jul 02, 2002
Posts: 158
maybe the problem is related to the following:
I send info to the bean from my jsp like this:

in my bean, I set up variables to hold the values sent via "card1" parameter, "card2" parameter, etc like this:

here is the method that is giving me an error msg:

I don't call upon this method from my JSP, but I think it is causing an error because it may be trying to return the parameter called called "card1" which came in as a String from the JSP ???
[ April 02, 2003: Message edited by: david eberhardt ]
david eberhardt
Ranch Hand

Joined: Jul 02, 2002
Posts: 158
Originally posted by Bear Bibeault:
You didn't show how you are accessing the Card1 property from the JSP. From the error message, I'm assuming you are trying to set it from an int.

Bear;
You steered me into the right direction - the problem was the getCard() methods; orignally I had:

When I set the card1, I brought in the value as a String, when I attempted to get card1, I used an int return type.
So i changed the two methods to be consistent with each other:

For some reason, unknown to me at this time, the getter and setter methods for a particular property (int card1) need to match up in regards to the arg type supplied to the setter and the return type of the getter. This is somewhat of a guess on my part.
thanks for the help.
[ April 02, 2003: Message edited by: david eberhardt ]
 
 
subject: weird error when using a java bean with my jsp