Hi,
i have a very simple html form, jsp and bean. In the form i input values for name, email and age. The jsp simply has to return and display those values. However im getting null values and i cant figure out why (either im setting the property incorrectly or getting it incorrectly).
GetName2.html
=============
<jsp:useBean id="user" class="Test.UserData"
scope="session" />
<jsp:setProperty name="user" property="*" />
<html>
<body>
<form method=post action="GetName2.jsp">
Name?<input type=text name=username><br>
email?<input type=text name=email><br>
age?<input type=text name=age><br>
<input type=submit>
</form>
</body>
</html>
GetName2.jsp
============
<jsp:useBean id="user" class="Test.UserData"
scope="session" />
<html>
<body>
Name:<%= user.getUsername() %> <br>
Email:<%= user.getEmail() %><br>
Age: <%= user.getAge() %> <br>
</body>
</html>
UserData.java
=============
package Test;
public class UserData {
String username;
String email;
int age;
public void setUsername(String 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; }
}
Result(============================================================
Name:null
Email:null
Age: 0
Any idea? Im using Apache Tomcat 4 and JSDK 1.3.1
Thanks,
GC.
i have a very simple html form, jsp and bean. In the form i input values for name, email and age. The jsp simply has to return and display those values. However im getting null values and i cant figure out why (either im setting the property incorrectly or getting it incorrectly).
GetName2.html
=============
<jsp:useBean id="user" class="Test.UserData"
scope="session" />
<jsp:setProperty name="user" property="*" />
<html>
<body>
<form method=post action="GetName2.jsp">
Name?<input type=text name=username><br>
email?<input type=text name=email><br>
age?<input type=text name=age><br>
<input type=submit>
</form>
</body>
</html>
GetName2.jsp
============
<jsp:useBean id="user" class="Test.UserData"
scope="session" />
<html>
<body>
Name:<%= user.getUsername() %> <br>
Email:<%= user.getEmail() %><br>
Age: <%= user.getAge() %> <br>
</body>
</html>
UserData.java
=============
package Test;
public class UserData {
String username;
String email;
int age;
public void setUsername(String 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; }
}
Result(============================================================
Name:null
Email:null
Age: 0
Any idea? Im using Apache Tomcat 4 and JSDK 1.3.1
Thanks,
GC.