• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

using one bean across several forms

Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application the user chooses an 'id' from a list (choice.jsp) and then is brought to a number of html forms (6 jsp files in total) where they fill out different information in each of the forms.
Each form must be populated by information from the database, and each time a change is made to a form that change must be recorded in the database.
The primary key is the 'id' so i must pass this to each of the forms so as they can get the correct record information for that 'id'.
I was going to use an id-bean with session scope for the 'id' and indivdual beans with request scope for each of the forms.
When the user goes from choice.jsp to the first form they will be first brought to a servlet which will set the 'id' attribute in the id-bean and retrieve all the database fields for that form and put the info in that form's bean, each of the form.jsp's will have their own servlet that will get the fields from the database.
Will this type of approach work, and as well sometimes i may want to add a new user , so their will be no 'id' field at the start, how do i make sure the 'id' of the last user is not still held in the id-form so no information will be retrieved from the database?
Thanks in advance
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Putting the key into the session is indeed the best way.
Do NOT put the database Connection or the ResultSet into the session as that can have disastrous results!
Something about .... going for a swim. With this tiny ad ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic