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
posted 12 years ago
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!