What is the error in the following code, I want to insert the records only when the button is pressed. Please teach me how to declare methods in JSP Code: <%@page import="java.sql.*;"%> <html> <title> </title> <head> <%! int rn; String sn; Connection conn=null; Statement stm; String s; ResultSet r;%> <% try { Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:first", "", ""); out.println ("Database Connected."); stm=conn.createStatement(); s="select * from student"; r=stm.executeQuery(s); //stm.executeUpdate(s); while(r.next()) { rn=r.getInt("rno"); sn=r.getString("sname"); } } catch(Exception e) { out.println(e.toString()); } void add() { String s = "insert into student(rno,sname)values(' " & rno.value & " ', ' " &snam.value & " ')"; r=stm.executeUpdate(s); } %> <body> <form> Roll Number:<input type="text" name="rno" value="<%=rn%>"> Student Name:<input type="text" name="snam" value="<%=sn%>"> <input type="button" value="Insert" onclick="add()"> </form> </body> </html>