<html>   
    <head>   
        <script>   
            function goSubmit()   
            {   
                document.frm.submit();   
            }   
        </script>   
    </head>   
    <body>   
        <form action ="view1.jsp" method="post" name="frm">   
  
            <table>   
                <tr>   
                    <td>   
                        <input type="radio" name="rg" value="faculty"   onClick="goSubmit()"/>   
                    </td>   
  
                    <td>   
                        <input type="radio" name="rg" value="date"  onClick="goSubmit()"/>   
                    </td>   
  
                    <td>   
                        <input type="radio" name="rg" value="content"  onClick="goSubmit()">   
                    </td>   
                </tr>   
            </table>   
        </form>   
    </body>   
</html>  
<html>
    <head>
        <script>
            function goSubmit()
            {
                document.frm.submit();
            }
        </script>
    </head>
    <body>
        <form action ="view1.jsp" method="post" name="frm">

            <table>
                <tr>
                    <td>
                        <input type="radio" name="rg" value="faculty"   onClick="goSubmit()"/>
                    </td>

                    <td>
                        <input type="radio" name="rg" value="date"  onClick="goSubmit()"/>
                    </td>

                    <td>
                        <input type="radio" name="rg" value="content"  onClick="goSubmit()">
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

this is my code i lost the focus on which radio button is selected after submiting the form

What do you mean lost focus. All we see here is the same code posted twice. Do you submit at the same page? If yes then what happens is that the page reloads.
You need to take the value of the radio button from the request and set the attribute "checked" to the selected radio button.
Take the value and use java scriplets (if statements) to decide which button needs to have the "checked"

sorry i paste the code twice.

<html>
    <head>
        
    </head>
</html>
<body>
    <form action="sample.jsp" method="get" name="frmTest">
        <table>
            <tr>
                <td>
                    <input type="radio" name="rg" value="faculty" checked="false"/>
                </td>
                <td>
                    <input type="radio" name="rg" value="date" checked="false"/>
                </td>
                <td>
                    <input type="radio" name="rg" value="content" checked="false">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

consider the above code it has all the three buttons are checked false
but at run the program automatically the last button is selected, how to this happened?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.