• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to retain the old values?

 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm creating a quiz application,I'm displaying one question per page and after the user clicks next i increnent a counter which is used to iterate over the collection of Question objects,and the next Question with options is displayed...I also want a previous functionality so i have a Previous button in the JSP,when i click the previous button i decrement the counter and the Page is generated again.But i want to retain the user's options.

Test.jsp
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could save his/her options in session scope or the database and then display them again. I think it would be better if the client browser handles what question should be chosen next with the use of parameters (hidden if necessary). That way you dont have to increment or decrement counts, unless of course the collection of questions is generated randomly.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my online exam applications I create an object to hold each user's information - present question number, answers so far, indexes of each question in the main question script, etc. - Naturally the reference to the object is stored in the session and thats the only thing that is stored there. This approach lets the user move backwards and forwards through the test, jump to a marked question, etc.

By making the object Serializable you have the possibility of saving and resuming the test.

Bill
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill and John,
I will try it out using Bill's approach and get back to you.


Regards,
Srikkanth
reply
    Bookmark Topic Watch Topic
  • New Topic