how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL

Ads
 

how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL

<html>
  <head>
    <title>online exam</title>
  </head>
  <body>
      <div align="center">
          <form method="post" action="Tab">
          <p>4.what is currency of USA?</p>
         <input type="radio" name="d"  onclick="getAnswer('a')" value="a "/>dollar &nbsp;
          <input type="radio" name="d" onclick="getAnswer('b')" value="b "/>pound &nbsp;
          <input type="radio" name="d"  onclick="getAnswer('c')"  value="c "/>rupees &nbsp;
          <input type="radio" name="d"  onclick="getAnswer('d')"   value="d "/>yen<br />
           </form>
           </div>
</body>
</html>

package src;

import java.io.*;
import java.net.*;
import java.sql.*;

import javax.servlet.*;

import javax.servlet.http.*;
public class Tab extends HttpServlet {
           protected void processRequest(HttpServletRequest request, HttpServletResponse response throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        int count=0,wrng=0;

         String radio0=request.getParameter("a");
         out.println(radio0);
        if("c".equals(radio0))
           count++;
        else
                wrng++;
          out.println("<html><head><title>result</title></head><body>" +
                "<div align=\"center\"><h1><u>Result</u></h1><p>correct answers are:</p>"+count+"<br/><p>wrong answers are :</p>"+wrng+"</div></body></html>");
        out.close();
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }


    public String getServletInfo() {
        return "Short description";
    }

}

Here the radio0 returns null value.pls advice me

View Answers

Ads









Related Tutorials/Questions & Answers:
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
Advertisements
Java radio buttons and button groups two values
Java radio buttons and button groups two values
radio buttons
3 RADIO BUTTONS
pyspark dataframe drop null - how to drop row with null values
how to insert values from jsp into ms access
how to generate automatic bill based on selected values using jsp/javascript?
How to access session values through Ajax?
method returning null on JSP page.Plz HELP!!!
method returning null on JSP page.Plz HELP!!!
access into radio button
how to retrieve data from table with runtime values in sql?
How to store two integer value in a separate file and retrieve those values
pass radio button values to next page
How to retrieve array values from html form to jsp?
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to display selected checkboxes dynamically using jsp
retrieve multiple attribute values
retrieve multiple attribute values
retrieve multiple attribute values
when radio button is selected corresponding jsp page should open
Retrieve value of radio button from database to form
how to retrieve the id value itself from the access database to drop down listbox in jsp
prog. using radio buttons for simple calculator
prog. using radio buttons for simple calculator
ModuleNotFoundError: No module named 'django-null-values'
how to retrieve data from database
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB

Ads