This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

keeping a bean alive

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give them plenty of water and sunlight
 
kajal sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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="*"/>
</jsp:useBean>
but they are null.
If I use scope =request then it is working.
Any help from java guru's
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kajal,
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
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maha ,
It is working now.Your help solved my problem.
You are really a great person.
with regards
kajal
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic