title: Get the selected or checked radio button value in JSP
body: <p>I have written a JSP program to get a list of some values from a MySQL database in the form of 4 radio buttons (meaning 4 values from the database) which is working fine.<br>
  I am also storing the selected radio button in a session which is showing <code>true</code> when I select a radio button and click on <code>next</code>, but I want to get all the selected values on submit button. I have provided an action for the "submit" button in another JSP page, meaning I want to show the values on a new JSP page.</p>
  
  <p>I have three questions coming from the database. That is why I have a <code>&lt;a href&gt;Next&lt;/a&gt;</code> for next so that I can view the questions one by one.<br>
  Every question has 4 options and the values I am getting in a list (<code>ansList.get(i)</code>) are in the form of radio buttons and every selected radio buttons value I need to show in a new JSP page.  </p>
  
  <p>I tried to use <code>request.getParameter("easy_answers")</code> in my new JSP page, but I am getting <code>null</code>.</p>
  
  <p>What do I need to do to get the values of the selected radio buttons?</p>
  
  <pre><code>&lt;%
  Server_Sql server_Sql = new Server_Sql();
  String ques_id = request.getParameter("easy_questions_id");
  String answer = request.getParameter("answers");
  int ques = Integer.parseInt(ques_id);
  int next_question = ques + 1;
  String answer_selected = request.getParameter("answer_selected");
  Boolean ans_selected = Boolean.valueOf(answer_selected);
  if (ans_selected == true) {
      session.setAttribute("ques_id", ans_selected);
  }
  String questions = server_Sql.getQuestions(ques);
  System.out.println("Question is " + questions);
  List&lt;String&gt; ansList = server_Sql.getAnswers(ques);
  server_Sql.close_connection();
  %&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h3&gt;
      &lt;%=questions%&gt;&lt;/h3&gt;
  &lt;br&gt;
  &lt;h3&gt;
      &lt;%
          for (int i = 0; i &lt; ansList.size(); i++) {
      %&gt;
      &lt;form&gt;
          &lt;input type="radio" name="easy_answers" value="answers"
              checked="checked"&gt;
          &lt;%=ansList.get(i)%&gt;&lt;br&gt;
          &lt;%
              }
          %&gt;
      &lt;/form&gt;
  &lt;/h3&gt;
  &lt;br&gt;
  &lt;%
      if (ques == 3) {
  %&gt;
  &lt;form action="results.jsp" method="get"&gt;
      &lt;div&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;%
      } else {
  %&gt;
  &lt;div align="right"&gt;
      &lt;a
          href="http://localhost:8082/StudentsServer/questions.jsp?
          answer_selected=true&amp;easy_questions_id=
          &lt;%=next_question%&gt;"&gt;Next&lt;/a&gt;
  &lt;/div&gt;
  &lt;%
      }
  %&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Anything more you want me to elaborate on, please let me know..</p>