Two Laptop Bag
The moose likes Servlets and the fly likes keeping a bean alive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "keeping a bean alive" Watch "keeping a bean alive" New topic

keeping a bean alive

kajal sharma

Joined: Oct 04, 2000
Posts: 22
Dear java guru,
I have got series of three .jsp form which is going to be filled by user .
I am using beans with each .jsp form.
Iam also using
ResourceBundle bundle =null;
public void jspInit() {
bundle = ResourceBundle.getBundle("login");
so that mapping & validation of form fields to bean fields could be done easly.

For single form I was using scope ="request"
but if I use scope="session" then my field are not getting initialized.
How could I keep my bean initialized with value till the third form so that I could insert in database when all the forms are filled.
I am new to jsp & servlets .
Please advice and help me
kajal sharma
Dean Tomlinson

Joined: Feb 28, 2001
Posts: 8
basically you need to use a separate jsp session bean to hold the data the you want to persist between pages.
you can use your page worker beans, (the ones you currently have for handling requests parameters), to update the session bean.
on your 3rd page you can get the property values from the session bean, in exactly the same way you would get from your page bean.
hope this helps
kajal sharma

Joined: Oct 04, 2000
Posts: 22
dean tomlinson,
I am having one bean per form to with setter and getter method for all fields in form.
If I am using request I could set and get method for a request.
And as submit button on a second jsp is again a request so my earlier bean object is lost.
How to keep my beans alive till last form and call it in my servlet to insert record in DB
any suggestion
kajal sharma
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

Give them plenty of water and sunlight

Visit my download page
kajal sharma

Joined: Oct 04, 2000
Posts: 22
I am using
<jsp:useBean id="report1" class="login.Report1" scope="session" />

is this a way to make session bean.
I am setting the propertires
<jsp:useBean id="report1" class="login.Report1" scope="session">
<jsp:setProperty name="report1" property="*"/>
but they are null.
If I use scope =request then it is working.
Any help from java guru's
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
I tested your situation with this sample code. Able to set session scoped bean's properties with incoming request prarameters with "*". Please check.
Also please check the foll. conditions.

[This message has been edited by maha anna (edited March 01, 2001).]
kajal sharma

Joined: Oct 04, 2000
Posts: 22
Thanks Maha ,
It is working now.Your help solved my problem.
You are really a great person.
with regards
I agree. Here's the link:
subject: keeping a bean alive
It's not a secret anymore!