title: How to retrieve the values from previous jsp page to result page?
body: <p>I am creating a quiz application. Here, there are 5 jsp pages with 5 different quizes. If I use 1 jsp page and result page, it is working fine..i.e; It is redirecting from QuizPage5.jsp and show the result in ResultPage.jsp.
  I need to show all the results from QuizPage1.jsp, QuizPage2.jsp, QuizPage3.jsp, QuizPage4.jsp and QuizPage5.jsp to ResultPage.jsp.</p>
  
  <p>I used </p>
  
  <p>in jsp1 to pass value.</p>
  
  <pre><code>&lt;form action=""&gt;
  &lt;input type="hidden" name="hidden" value="hidden"&gt;
  &lt;input type="submit" value="submit"&gt;&lt;/form&gt;
  </code></pre>
  
  <p>in jsp2 to get value</p>
  
  <pre><code>String value=request.getParameter("hidden");
  </code></pre>
  
  <p>But, I am getting <code>java.lang.NullPointerException</code></p>
  
  <p>Here is my code..</p>
  
  <p>QuizPage1.jsp</p>
  
  <pre><code>&lt;html&gt;  
      &lt;head&gt;  
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
              &lt;script language="JavaScript"&gt;  
  
              function check()  
                 {  
                     var radio_choice = false;  
                     for (counter = 0; counter &lt; myform.grp.length; counter++)  
                      {  
                          if (myform.grp[counter].checked)  
                          radio_choice = true;  
                      }  
                          if (!radio_choice)  
                           {  
                              alert("Please select one.")  
                              return (false);  
                           }  
                           return(true);  
                       }  
  &lt;/script&gt;  
      &lt;/head&gt;  
     &lt;body&gt; 
          &lt;h3&gt;Quiz No.1&lt;/h3&gt;
  
          Q1.Which one of the following is the Capital of India?&lt;br&gt;&lt;br&gt;  
          &lt;form action="QuizPage2.jsp" method="post" name="myform" onsubmit="return check();"&gt;  
              &lt;input type="radio" name="grp" value="New Delhi" &gt;New Delhi&lt;br&gt;  
               &lt;input type="radio" name="grp" value="Kolkata" &gt;Kolkata&lt;br&gt;  
                   &lt;input type="radio" name="grp" value="Chennai" &gt;Chennai&lt;br&gt;  
                       &lt;input type="radio" name="grp" value="Mumbai" &gt;Mumbai&lt;br&gt;  
                       &lt;br&gt;&lt;br&gt;&lt;input type="submit" value="Next Question"&gt; 
                       &lt;input type="hidden" name="hidden" value="grp"&gt;
                       &lt;input type="submit" value ="Back" onclick="window.history.back();"/&gt; 
  
          &lt;/form&gt;  
        &lt;/body&gt;
  
  
  
  &lt;/html&gt; 
  </code></pre>
  
  <p>QuizPage2.jsp</p>
  
  <pre><code>&lt;html&gt;  
      &lt;head&gt;  
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
              &lt;script language="JavaScript"&gt;  
  
              function check()  
                 {  
                     var radio_choice = false;  
                     for (counter = 0; counter &lt; myform2.grp2.length; counter++)  
                      {  
                          if (myform2.grp2[counter].checked)  
                          radio_choice = true;  
                      }  
                          if (!radio_choice)  
                           {  
                              alert("Please select any one Answer");  
                              return (false);  
                           }  
                           return(true);  
                       }  
  &lt;/script&gt;  
      &lt;/head&gt;  
      &lt;body&gt;  
          &lt;h3&gt;Quiz No.2&lt;/h3&gt;
  
          Q2. Where is Chennai Located?&lt;br&gt;&lt;br&gt;  
          &lt;form action="QuizPage3.jsp"method="post" name="myform2" onsubmit="return check();"&gt;  
              &lt;input type="radio" name="grp2" value="Karnataka" &gt;Karnataka&lt;br&gt;  
               &lt;input type="radio" name="grp2" value="Tamilnadu" &gt;Tamilnadu&lt;br&gt;  
                   &lt;input type="radio" name="grp2" value="Andhra Pradesh" &gt;Andhra Pradesh&lt;br&gt;  
                       &lt;input type="radio" name="grp2" value="Maharashtra" &gt;Maharashtra&lt;br&gt;  
                       &lt;br&gt;&lt;br&gt;&lt;input type="submit" value="Next Question"&gt;  
                        &lt;input type="hidden" name="hidden" value="grp2"&gt;
                       &lt;input type="submit" value ="Back" onclick="window.history.back();"/&gt; 
  
  
          &lt;/form&gt;  
          &lt;%
              String s1=request.getParameter("grp");
           %&gt;
        &lt;/body&gt;  
  &lt;/html&gt; 
  </code></pre>
  
  <p>QuizPage3.jsp</p>
  
  <pre><code>&lt;html&gt;  
      &lt;head&gt;  
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
              &lt;script language="JavaScript"&gt;  
  
              function check()  
                 {  
                     var radio_choice = false;  
                     for (counter = 0; counter &lt; myform3.grp3.length; counter++)  
                      {  
                          if (myform3.grp3[counter].checked)  
                          radio_choice = true;  
                      }  
                          if (!radio_choice)  
                           {  
                              alert("Please select any one Answer");  
                              return (false);  
                           }  
                           return(true);  
                       }  
  &lt;/script&gt;  
      &lt;/head&gt;  
      &lt;body&gt;  
          &lt;h3&gt;Quiz No.3&lt;/h3&gt;
          Q3. What is the largest state in the USA&lt;br&gt;&lt;br&gt;  
          &lt;form action="QuizPage4.jsp"method="post" name="myform" onsubmit="return check();"&gt;  
              &lt;input type="radio" name="grp3" value="New York" &gt;New York&lt;br&gt;  
               &lt;input type="radio" name="grp3" value="Alaska" &gt;Alaska&lt;br&gt;  
                   &lt;input type="radio" name="grp3" value="California" &gt;California&lt;br&gt;  
                       &lt;input type="radio" name="grp3" value="Melbourne" &gt;Melbourne&lt;br&gt;  
                       &lt;br&gt;&lt;br&gt;&lt;input type="submit" value="Next Question"&gt;  
                       &lt;input type="hidden" name="hidden" value="grp3"&gt;
                       &lt;input type="submit" value ="Back" onclick="window.history.back();"/&gt; 
  
          &lt;/form&gt;  
          &lt;%
              String s2=request.getParameter("grp2");
           %&gt;
        &lt;/body&gt;  
  &lt;/html&gt; 
  </code></pre>
  
  <p>QuizPage4.jsp</p>
  
  <pre><code>&lt;html&gt;  
      &lt;head&gt;  
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
              &lt;script language="JavaScript"&gt;  
  
              function check()  
                 {  
                     var radio_choice = false;  
                     for (counter = 0; counter &lt; myform4.grp4.length; counter++)  
                      {  
                          if (myform4.grp4[counter].checked)  
                          radio_choice = true;  
                      }  
                          if (!radio_choice)  
                           {  
                              alert("Please select any one Answer");  
                              return (false);  
                           }  
                           return(true);  
                       }  
  &lt;/script&gt;  
      &lt;/head&gt;  
      &lt;body&gt;  
          &lt;h3&gt;Quiz No.4&lt;/h3&gt;
          Q4. The famous Dilwara Temples are situated in&lt;br&gt;&lt;br&gt;  
          &lt;form action="QuizPage5.jsp"method="post" name="myform" onsubmit="return check();"&gt;  
              &lt;input type="radio" name="grp4" value="Uttar Pradesh" &gt;Uttar Pradesh&lt;br&gt;  
               &lt;input type="radio" name="grp4" value="Maharashtra" &gt;Maharashtra&lt;br&gt;  
                   &lt;input type="radio" name="grp4" value="Andhra Pradesh" &gt;Andhra Pradesh&lt;br&gt;  
                       &lt;input type="radio" name="grp4" value="Rajasthan" &gt;Rajasthan&lt;br&gt;  
                       &lt;br&gt;&lt;br&gt;&lt;input type="submit" value="Next Question"&gt; 
                       &lt;input type="hidden" name="hidden" value="grp4"&gt;
                       &lt;input type="submit" value ="Back" onclick="window.history.back();"/&gt; 
  
          &lt;/form&gt; 
          &lt;%
              String s3=request.getParameter("grp3");
           %&gt;
        &lt;/body&gt;  
  &lt;/html&gt; 
  </code></pre>
  
  <p>QuizPage5.jsp</p>
  
  <pre><code>&lt;html&gt;  
      &lt;head&gt;  
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
              &lt;script language="JavaScript"&gt;  
  
              function check()  
                 {  
                     var radio_choice = false;  
                     for (counter = 0; counter &lt; myform5.grp5.length; counter++)  
                      {  
                          if (myform5.grp5[counter].checked)  
                          radio_choice = true;  
                      }  
                          if (!radio_choice)  
                           {  
                              alert("Please select any one Answer");  
                              return (false);  
                           }  
                           return(true);  
                       }  
  &lt;/script&gt;  
      &lt;/head&gt;  
      &lt;body&gt;  
          &lt;h3&gt;Quiz No.5&lt;/h3&gt;
          Q5. The Indian Institute of Science is located at&lt;br&gt;&lt;br&gt;  
          &lt;form action="ResultPage.jsp"method="post" name="myform" onsubmit="return check();"&gt;  
              &lt;input type="radio" name="grp5" value="Chennai" &gt;Chennai&lt;br&gt;  
               &lt;input type="radio" name="grp5" value="Bangalore" &gt;Bangalore&lt;br&gt;  
                   &lt;input type="radio" name="grp5" value="Mumbai" &gt;Mumbai&lt;br&gt;  
                       &lt;input type="radio" name="grp5" value="Hyderabad" &gt;Hyderabad&lt;br&gt;  
                       &lt;br&gt;&lt;br&gt;&lt;input type="submit" value="Show Result"&gt; 
                       &lt;input type="hidden" name="hidden" value="grp5"/&gt;
  
  
          &lt;/form&gt; 
          &lt;%
              String s4=request.getParameter("grp4");
           %&gt;
        &lt;/body&gt;  
  &lt;/html&gt; 
  </code></pre>
  
  <p>ResultPage.jsp</p>
  
  <pre><code>&lt;html&gt;  
      &lt;head&gt;  
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
          &lt;title&gt;Quiz Result&lt;/title&gt;  
      &lt;/head&gt;  
      &lt;body&gt;  
            &lt;%  
       String answer="New Delhi";  
       String s1=request.getParameter("grp");  
       if(s1.equals(answer))  
           {  
          out.println("Correct Answer");  
           }  
       else  
           {out.println("Wrong Answer! The Correct Answer is :"+answer);  
       }  
      %&gt; 
      &lt;%  
       String answer2="Tamilnadu";  
       String s2=request.getParameter("grp2");  
       if(s2.equals(answer2))  
           {  
          out.println("Correct Answer");  
           }  
       else  
           {out.println("Wrong Answer! The Correct Answer is :"+answer2);  
       }  
      %&gt; 
      &lt;%  
       String answer3="Alaska";  
       String s3=request.getParameter("grp3");  
       if(s3.equals(answer3))  
           {  
          out.println("Correct Answer");  
           }  
       else  
           {out.println("Wrong Answer! The Correct Answer is :"+answer3);  
       }  
      %&gt; 
      &lt;%  
       String answer4="Rajasthan";  
       String s4=request.getParameter("grp4");  
       if(s4.equals(answer4))  
           {  
          out.println("Correct Answer");  
           }  
       else  
           {out.println("Wrong Answer! The Correct Answer is :"+answer4);  
       }  
      %&gt; 
          &lt;%  
           String answer5="Bangalore";  
           String s5=request.getParameter("grp5");  
           if(s5.equals(answer5))  
               {  
              out.println("Correct Answer");  
               }  
           else  
               {out.println("Wrong Answer! The Correct Answer is :"+answer5);  
           }  
          %&gt; 
  
  
      &lt;/body&gt; 
  &lt;/html&gt; 
  </code></pre>
  
  <p>Your help is highly appreciated. Thanks in Advance</p>