Hi guys!
I have to write a website with JSP and Servlets which displays a questionnaire and gets the result of the user.
I've already written the question object, a questionnaire (random list of questions) and the questions library.
Now my Servlet generates an instance of the questionnaire and displays the questions. My problem is I don't know how to get the results. I can get the answers but AFAIK every time I load a Servlet it would generate a new questionnaire and the answers would be useless. So how can I pass the answers to the correct questionnaire. Or how can I pass the questionnaire to my new Servlet?
Thanks a lot.
Edit: Here is the code for the questionnaire:
public abstract Question getNextQuestion();
public abstract void setResult(ArrayList<Boolean> answers);
public abstract int[] getResult();
Basically I create a questionnaire, and get via getNextQuestion()
the next question until there are no more. then the user will hit the submit button and i'll have to read the answers and pass it to the questionnaire (setResult()
for the actual question). When there is no more question I'll use retResult()
for the result.
Hope this helps. I can't give u any JSP code since I have no JSP written yet