Hi all,
i am new to javabeans and JSP, i have some problem to retrieve value from beans, any help will be appreciate.
my index.jsp has a from
<form action="update.jsp" method="POST">
userName <input type="text" name="userName" />
<br>
realName <input type="text" name="realName" />
<br>
<input type="submit" value="Log In" />
</form>
which POST to update.jsp,
update.jsp retrieves userName
<jsp:useBean id="simple" class="bean.UserBean">
<jsp:setProperty name="simple" property="*"/>
</jsp:useBean>
<body>
<h1>
User <jsp:getProperty name="simple" property="userName" />
</h1>
<input type="button" onclick = "location.href='next.jsp'" value="next">
i am OK at this point. But if i want to go to next.jsp which display realName, i got null.
next.jsp :
<jsp:useBean id="simple" class="bean.UserBean">
</jsp:useBean>
<body>
<h1>Hello <jsp:getProperty name="simple" property="realName" /></h1>
</body>
UserBean :
public class UserBean implements java.io.Serializable {
private String userName;
private String realName;
/** No-arg constructor (takes no arguments). */
public UserBean() {
}
/**
* Property <username>name</username> (note capitalization) readable/writable.
*/
public String getuserName() {
return this.userName;
}
/**
* Setter for property <username>name</username>.
* @param name
*/
public void setuserName(String userName) {
this.userName = userName;
}
/**
* Property <realname>name</realname> (note capitalization) readable/writable.
*/
public String getRealName() {
return this.realName;
}
/**
* Setter for property <realname>name</realname>.
* @param name
*/
public void setRealName(String realName) {
this.realName = realName;
}
}
I am really new to JavaBeans, any help please!