Jsp Help ....Beans

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bigbule33
    New Member
    • Oct 2006
    • 1

    #1

    Jsp Help ....Beans

    I am starting to learn JSP and this is a simple file that I got from a tutorial ..however when I run it i get the following error

    when I click submit on the HTML page, it says ....its not able to find the class. ....UserData cannot be resolved to a type

    Can some one tell me where to put the class file so that the jsp page can find it


    The UserData.class is in C:\Program Files\Apache Software Foundation\Tomc at 5.5\webapps\ROO T\WEB-INF\ directory
    My .html and .jsp pages are in C:\Program Files\Apache Software Foundation\Tomc at 5.5\webapps\ROO T\ directory.


    <HTML>
    <BODY>
    <FORM METHOD=POST ACTION="SaveNam e.jsp">
    What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>
    What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
    What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
    <P><INPUT TYPE=SUBMIT>
    </FORM>
    </BODY>
    </HTML>

    this is the code in SaveName.jsp

    <jsp:useBean id="user" scope="session" class="UserData " />
    <jsp:setPropert y name="user" property="*"/>
    <HTML>
    <BODY>
    <A HREF="NextPage. jsp">Continue</A>
    </BODY>
    </HTML>

    the code in UserData is as follows

    class UserData
    {
    String username;
    String email;
    int age;

    public void setUsername(Str ing value)
    {
    username = value;
    }

    public void setEmail(String value)
    {
    email = value;
    }

    public void setAge(int value)
    {
    age = value;
    }

    public String getUsername()
    {
    return username;
    }

    public String getEmail()
    {
    return email;
    }

    public int getAge()
    {
    return age;
    }
    }

    This is the code in NextPage.jsp

    <jsp:useBean id="user" class="UserData " scope="session"/>
    <HTML>
    <BODY>
    You entered<BR>
    Name: <%= user.getUsernam e() %><BR>
    Email: <%= user.getEmail() %><BR>
    Age: <%= user.getAge() %><BR>
    </BODY>
    </HTML>
Working...