Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to retrieve radio button value on servlet from a jsp ?

843842May 30 2008 — edited Jun 3 2008
Hi folks...

I have a jsp page where there are 4 radio buttons with same name. I post the form on clicking a normal button (not submit).. After i click button script which is present on same jsp gets called and it submits the form to a servlet. When i try to access the radio button value on servlet using => request.getParameter("engine") it gives me null value.. Can some one help me in this regard ??
I am also posting the jsp code for your reference.. Have a look and let me know about any solution..
----------------------------------------------------------------------------------------------------------------------------------------------------
<html>
<BODY >
<form name="Input_Form" enctype="multipart/form-data" method="post">

<TABLE style="WIDTH: 745px; HEIGHT: 28px" cellSpacing=1 cellPadding=1 width=488
align=center border=1>
<TR>
<TD><INPUT name=radio1 type=radio value="TAG">TAG</TD>
<TD><INPUT name=radio1 type=radio value="EBMT" >EBMT</TD>
<TD><INPUT name=radio1 type=radio value="ANAL-GEN">ANAL-GEN</TD>
<TD><INPUT name=radio1 type=radio
value="SMT">SMT</TD></TR></TABLE></P>
</TABLE >

<input type="Button" Id="Submit_Button_Direct" name="Submit_Button_Direct" value="Direct Translation" OnClick="javascript:return Submit_Input_Direct();">

</body>
</html>
<script language="JavaScript">
function Submit_Input_Direct()
{
var buttonDirect = document.getElementById("Submit_Button_Direct");
buttonDirect.disabled = "true";
for(var i=0; i<document.Input_Form.radio1.length; i++)
{
if(document.Input_Form.radio1.checked)
{
var name = document.Input_Form.radio1[i].value;
alert("radio selected : "+radio);
//document.getElementById("engine_Id").value=name ;

}

}
document.Input_Form.action="TranslateDirectTXT";
document.forms.Input_Form.submit();
return true ;
}
</script>
------------------------------------------------------------------------------------------------------------------------------------------
you can also observe one comment //document.getElementById("engine_Id").value=name ;
where i tried to store the value in hidden field but even that couldnt worked..
Is the attribute in form tag is causing some problem ? (i.e. enctype="multipart/form-data" ) If so then what could be the solution ??
Thank you all for attending my problem...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2008
Added on May 30 2008
11 comments
4,812 views