M
Matt S.
Hello all,
I simply want to write a JSP that fills in the fields of a javabean
from a form, and be able to access the bean for the rest of the
session. My JSP code looks like this:
<jsp:useBean id="numbean" class="test.TestBean" scope="session">
<jsp:setProperty name="numbean" property="*"/>
</jsp:useBean>
<html>
<body>
<form method=post>
<input type="text" name="num"/>
<input type="submit" value="Submit"/>
</form>
<p><jsp:getProperty name="numbean" property="num"/></p>
</body>
</html>
My bean code is similarly simple:
public class TestBean {
private int num = 0;
public TestBean() {
}
public int getNum() {
return this.num;
}
public void setNum(int num) {
this.num = num;
}
}
Now, here is the thing, with the above JSP, the num property in the
bean never seems to change. However, if I change the scope to 'page',
then it seems to work fine, changing the property whenever I Submit
the form. What is going on here? Am I missing something simple?
Thanks for the help,
Matt
I simply want to write a JSP that fills in the fields of a javabean
from a form, and be able to access the bean for the rest of the
session. My JSP code looks like this:
<jsp:useBean id="numbean" class="test.TestBean" scope="session">
<jsp:setProperty name="numbean" property="*"/>
</jsp:useBean>
<html>
<body>
<form method=post>
<input type="text" name="num"/>
<input type="submit" value="Submit"/>
</form>
<p><jsp:getProperty name="numbean" property="num"/></p>
</body>
</html>
My bean code is similarly simple:
public class TestBean {
private int num = 0;
public TestBean() {
}
public int getNum() {
return this.num;
}
public void setNum(int num) {
this.num = num;
}
}
Now, here is the thing, with the above JSP, the num property in the
bean never seems to change. However, if I change the scope to 'page',
then it seems to work fine, changing the property whenever I Submit
the form. What is going on here? Am I missing something simple?
Thanks for the help,
Matt