I am writing a simple JSP code that should take a textbox value, form a sql, execute and return the result to another text field. I get an empty result. The following is my code.
The driver is working and value is set if no condition in the statement like selecting first name if rownum<1 for example, so I am sure it is registered fine. 
<html>
<head>
<title>Holiday Master</title>
</head>
<body>
<%@ page import = "java.sql.*" %> 
<div>
        <input id="input1" name="Text1" type="text"><input id="input2" name="Text2" type="text"><input name="Button1" onclick="get_data()" type="button" value="button"></div>
<script>
function get_data()
{
<%
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");
    Statement stmt  = conn.createStatement();
    String sql2 = request.getParameter("input1"); 
    String sql="select last_name from employees where first_name ='"+sql2+"'";
    ResultSet rs = stmt.executeQuery(sql);
    try
    {
    if(rs!=null)
    {
    while(rs.next())
    {
    %>
   document.getElementById("input2").value="<%=rs.getString("last_name")%>";    
    <%
    }
    }        
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
    stmt.close();
    rs.close();
    conn.close();
    stmt=null;
    rs=null;
    conn=null;
    %>
}
</script>
</body>
</html>
 
     
    