i am having problem in this code, i have written //ERROR, where i am getting error....
PLEASE HELP
BASICALLUY, WHAT I AM DOING IS:-
I HAVE A GENERATE AND OK BUTTON, WHENEVER I CLICK GENERATE BUTTON, A NEW SET OF INFO IS RETRIEVED FROM THE DATABASE AND THE TEXT FIELDS ARE FILLED ACCORDINGLY, BUT THATS NOT HAPPENING :-(
PLEASE PLEASE PLEASE HELP......
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript">
function pat()
{
<% response.sendRedirect("#");
java.util.Date date=new java.util.Date();
String format="mm-dd-yyyy";
SimpleDateFormat sdf=new SimpleDateFormat();
String d=sdf.format(date);
String nm;
int ag;
String gen;
String des;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e)
{
}
Connection con=DriverManager.getConnection("jdbc:odbc:hospdsn");
PreparedStatement ps=con.prepareStatement("select pname,age,gender,dscrptn from patient where docref=? and curdate=? and meet=? LIMIT 1");
ps.setString(1, (String)session.getAttribute("name"));
ps.setString(2,d);
ps.setString(3,"no");
ResultSet rs=ps.executeQuery();
rs.next();
nm=rs.getString("pname");
ag=rs.getInt(2);
gen=rs.getString(3);
des=rs.getString(4);
%>
}
</script>
</head>
<body bgcolor="black"><center>
Hello <%= session.getAttribute("name") %>
<form action="pres.jsp">
<%
/* String nm;
int ag;
String gen;
String des;
java.util.Date date=new java.util.Date();
String format="mm-dd-yyyy";
SimpleDateFormat sdf=new SimpleDateFormat();
String d=sdf.format(date);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e)
{
}
Connection con=DriverManager.getConnection("jdbc:odbc:hospdsn");
PreparedStatement ps=con.prepareStatement("select pname,age,gender,dscrptn from patient where docref=? and curdate=? and meet=? LIMIT 1");
//ERROR
ps.setString(1, (String)session.getAttribute("name"));
ps.setString(2,d);
ps.setString(3,"no");
ResultSet rs=ps.executeQuery();
rs.next();
nm=rs.getString(1);
ag=rs.getInt(2);
gen=rs.getString(3);
des=rs.getString(4);
*/
%>
<h1><b><font color="red"><u>PATIENT'S INFORMATION</u></font></b></h1></center>
<table align=center border=0 bgcolor="black" cellspacing=2 cellpadding=2>
<br><br><tr><td><b><font color="red">Patient's Name:</font></b></td><td><input type="text" name="a1" value="<%=nm %>"></td></tr>
<br>
<tr><td><b><font color="red">Gender:</font></b></td><td><input type="text" name="gender" value="<%=gen%>">
</td></tr>
<tr><td><b><font color="red">Age:</font></b></td><td><input type="password" name="a2" value="<%=ag%>"></td></tr>
<tr><td><b><font color="red">Description:</font></b></td><td><textarea name="Description" cols=30 rows=5 ><%=des%></textarea></td></tr>
<tr><td></td><td>
<br>
<input type="submit" value="OK" ></td><td><input type="button" value="Generate" onclick="pat()"></tr>
</table>
</form>
</body>
</html>