I have a variable in my jsp page which i want to pass as an argument to a javascript function.How to do it?
code:-
<%
String ts=request.getParameter("testname");
session.setAttribute("tname", ts);
Connection con=null;
Statement s=null;
ResultSet r=null;
int t=60000;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:online_testing");
s=con.createStatement();
r=s.executeQuery("select * from "+ts+"");
String time=r.getString("duration");
t=Integer.parseInt(time)*60000;
}
catch(Exception e1)
{
response.setContentType("text/html");
out.println(e1.toString());
}
%>
<body onload="setTimeout('submitForm()',<%=t%>)">
It is taking only the initial value of t,not the updated one. How can I pass the value of variable "t" in function setTimeout() as an argument?