wood burning stoves 2.0*
The moose likes Servlets and the fly likes getProperty() problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getProperty() problem" Watch "getProperty() problem" New topic
Author

getProperty() problem

Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
I receive this error message when I run the following jsp:
org.apache.jasper.JasperException: Cannot find a method to read property 'lowerLimit' in a bean of type 'num.NumberGuessBean'
jsp:

<%@ page import = "num.NumberGuessBean" %>
<jsp:useBean id="numguess" class="num.NumberGuessBean" scope="session"/>
<jsp:setProperty name="numguess" property="*"/>
<html>
<head><title>Number Guess</title></head>
<body bgcolor="white">
<font size=4>
<% if (numguess.getSuccess()) { %>
Congratulations! You got it.
And after just <%= numguess.getNumGuesses() %> tries.<p>
<% numguess.reset(); %>
Care to <a href="numguess.jsp">try again</a>?
<% } else if (numguess.getNumGuesses() == 0) { %>
Welcome to the Number Guess game.<p>
Play with default limits ( a number between 0 and 100)<p>
or enter upper and lower limits.<p>

<form method=get>
Play with defaults?: <input type=radio name=default value="yes">Yes
<input type=radio name=default value="no">No
<\form>

<% if (numguess.getRadio().equals("no")) { %>

<form method=get>
Enter upper limit:<input type=text name=upperLimit>
Enter lower limit:<input type=text name=lowerLimit>
<\form>

<% numguess.reset(); %>

<% } %>

<form method=get>
What's your guess? <input type=text name=guess>
<input type=submit value="Submit">
</form>
<% } else { %>
Good guess, but nope. Try <b><%= numguess.getHint() %></b>.
You have made <%= numguess.getNumGuesses() %> guesses.<p>
I'm thinking of a number between <jsp:getProperty name="numguess" property="lowerLimit"/> and <jsp:getProperty name="numguess" property="upperLimit"/>.<p>
<form method=get>
What's your guess? <input type=text name=guess>
<input type=submit value="Submit">
</form>
<% } %>
</font>
</body>
</html>
the relevant part of the bean:
package num;
import java.util.*;
public class NumberGuessBean {
int answer;
boolean success;
String hint;
int numGuesses;
String radiochoice;
int lowerLimit=0;
int upperLimit=100;
String error;
public NumberGuessBean() {
reset();
}
public void setGuess(String guess) {
numGuesses++;
int g;
try {
g = Integer.parseInt(guess);
}
catch (NumberFormatException e) {
g = -1;
}
if (g == answer) {
success = true;
}
else if (g == -1) {
hint = "a number next time";
}
else if (g < answer) {
hint = "higher";
}
else if (g > answer) {
hint = "lower";
}
}
public void setRadio(String s) {
radiochoice=s;
}
public String getRadio() {
return radiochoice;
}
public void setLowerLimit( String lowerLimit) {
int l;
try {
l=Integer.parseInt(lowerLimit);
}
catch(NumberFormatException e) {
l=-1;
}
if (l==-1) {
error= "Please enter a number";
}
else {
this.lowerLimit=l;
}
}
public int getLowerLimit() {
return lowerLimit;
}
public void setUpperLimit(String upperLimit) {
int l;
try {
l=Integer.parseInt(upperLimit);
}
catch(NumberFormatException e) {
l=-1;
}
if(l==-1) {
error="Please enter a number";
}
else {
this.upperLimit=l;
}
}
public int getUpperLimit() {
return upperLimit;
}
Any help would be appreciated
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: getProperty() problem
 
Similar Threads
error with JSP and Bean
JSP BEAN Question
understang the JSP
server encountered an internal error ()
what is the problem??