problems with jsp:useBean session
843835Jan 20 2002 — edited Jan 20 2002Hi,
I'm have a bit of trouble with beans and their scope - would appreciate any help:
This book i'm working off defined session scope as meaning that the object will be available during any requests made by the same client within the current scope. What exactly does 'current scope' mean?
My problem is that as long as i'm in the current request, my bean works fine i.e. all the values are still set when I forward the request to another jsp page. But when I create a new request, all the fields in my bean are again initialize to null.
The code is below:
/***** techSupport.jsp ********/
<%@page errorPage="/errors.jsp" session="true" %>
<jsp:useBean id="object" scope="session" class="javabeans.TechSupportBean"/>
<jsp:setProperty name="object" property="*"/>
<jsp:forward page="regForm.jsp" />
/****** regForm.jsp ****/
<%@ page language="java" session="true" %>
<jsp:useBean id="object" scope="session" class="javabeans.TechSupportBean"/>
<jsp:setProperty name="object" property="*"/>
<html>
<head>
<title>Test Page</title>
</head>
<body>
Email: <jsp:getProperty name="object" property="email"/><br>
Program: <jsp:getProperty name="object" property="program"/><br>
Problem: <jsp:getProperty name="object" property="problem"/><br>
OS: <jsp:getProperty name="object" property="os"/><br>
<form action="regForm.jsp" method="post">
<input type="submit">
</form>
</body>
</html>
The first time regForm.jsp is loaded, I see the values for 'email', 'problem'..etc. When I press the submit button and reload the page, these value are no longer there.
Cheers,
Nim