This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of DevSecOps Adventures: A Game-Changing Approach with Chocolate, LEGO, and Coaching Games and have Dana Pylayeva on-line!
See this thread for details.
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

using one bean across several forms

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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!
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic