• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

using one bean across several forms

Posts: 13
  • Mark post as helpful
  • send pies
  • 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
  • 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!
Bring out your dead! Or a tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic