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

Ads

 
 
 

Share on Google+Share on Google+

salman
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
0 Answer(s)      4 years and 10 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

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Advertisements
Tutorials   
Java Spring Hibernate Struts Training email verification in e commerce application email verification in e commerce application EJB interceptors Demo How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ??? RUNNING EJB PROGRAMS Issue when deploying mdb jar in weblogic Weblogic8 server problem login module program login module program jsp project Lookup failed in SessionBean mahesh How to display single row from sql server 2005 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 Stateless Bean Error Stateless Session Bean Example Error EJB Deployment how to create a simple ejd session bean and how to do project setup Ejb Module Ejb Module EJB JSP - Checkbox remain checked although checked values should depend on values stored in a stateful session bean Session Bean Example Bean RMI ejb ejb webservices message driven bean example entity bean j2ee example programs Rose India Stateless Session Bean Example Question Coding with Ejb EJB with NetBeans Run a simple EJB code Run a simple EJB code Used Handicap Vans Issue in Stateless session bean example ejb ejb methods can be invoked by the container on a stateless session bean session Join problem with JPA Criteria Builder About Web-Logic Abut Deploying and Developing Web-Logic in JDK1.5 version to run the EJB managing the transactions Pagination DataGrid without DataBase Many To Many annotation in ejb use of ejb 3.0

Ads

 
Advertisement null

Ads