This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retain the old values?

 
Srikkanth Mohanasundaram
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
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic