[英]How to display the result in last page by collecting the results from previous jsp page?
我正在創建測驗應用程序。 在這里,有5個具有5個不同測驗的jsp頁面。 我需要顯示從QuizPage1.jsp,QuizPage2.jsp,QuizPage3.jsp,QuizPage4.jsp和QuizPage5.jsp到ResultPage.jsp的所有結果。
我使用會話從所有jsp頁面獲取答案。 但是,我需要在最后一頁顯示結果。
問題1:錯誤答案-正確答案是.......問題2:錯誤答案-正確答案是.......問題3:錯誤答案-正確答案是................問題4 :錯誤答案-正確答案是.......問題5:錯誤答案-正確答案是................
我通過更改參數在每個jsp頁面中使用了該腳本。
<%
String s1=request.getParameter("grp");
request.getSession().setAttribute("s1", s1);
%>
有什么解決辦法嗎?
參考代碼- 如何從以前的jsp頁面到結果頁面檢索值?
<%
String theAnswer1 = ...
String userAnswer = (String)session.getAttribute("s1");
if (theAnswer.equals(userAnswer)) {
out.println("Answer1 is correct - woohoo!");
} else {
out.println("Question 1: Wrong answer - Correct answer is: " + theAnswer1)
}
%>
對答案2、3、4和5重復相同的模式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.