Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa EJB how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


salman
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
0 Answer(s)      2 years and 3 months ago
Posted in : EJB


<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


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com