JSP and Beans

Discussion in 'Software' started by anto, Oct 30, 2006.

  1. anto

    anto Private E-2

    I badly need some help with this. It is a project for college it is a number guess game I had the code working but then something happened and I keep getting this error:

    javax.servlet.ServletException: com/detiel/advjhtp1/jsp/beans/Check
    (wrong name: Check)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    and I don't know what it means Can any one help.


    The code for the JSP is:

    <jsp:useBean id = "check" scope = "session"
    class = "com.detiel.advjhtp1.jsp.beans.Check"/>

    <html>
    <head>
    <title>Number Guess</title>
    </head>


    <body>
    <% if (check.getWin()) { %>

    You've won after <%= check.getNumGuesses() %> tries.<p>

    <% check.reset(); %>

    Do you want to <a href="numguess.jsp">try again</a>?

    <% } else if (check.getNumGuesses() == 0) { %>

    Pick a number between 1 and 10.<p>

    <form method=get>
    Enter your guess. <input type=text name=guess>
    <input type=submit value="Submit">
    </form>

    <% } else { %>

    Nope. Try <b><%= check.getTip() %></b>.

    You have made <%= check.getNumGuesses() %> guesses.<p>

    I'm thinking of a number between 1 and 10.<p>

    <form method=get>
    Enter your guess. <input type=text name=guess>
    <input type=submit value="Submit">
    </form>

    <% } %>


    </body>
    </html>


    and the code for the Bean is:


    import java.util.*;

    public class Check
    {

    int answer;
    boolean win;
    String tip;
    int numGuesses;

    public Check()
    {
    reset();
    }

    public void setGuess(String guess)
    {
    numGuesses++;

    int i;

    i = Integer.parseInt(guess);

    {
    i = -1;
    }

    if (i == answer)
    {
    win = true;
    }
    else if (i == -1)
    {
    tip = "a number next time";
    }
    else if (i < answer)
    {
    tip = "higher";
    }
    else if (i > answer)
    {
    tip = "lower";
    }
    }

    public boolean getWin()
    {
    return win;
    }

    public String getTip()
    {
    return "" + tip;
    }

    public int getNumGuesses()
    {
    return numGuesses;
    }

    public void reset()
    {
    answer = Math.abs(new Random().nextInt() % 100) + 1;
    win = false;
    numGuesses = 0;
    }
    }


    Thanks for any help.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds