• 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to retain the old values?

 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic