• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

weird error when using a java bean with my jsp

 
david eberhardt
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
david eberhardt
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic