I am trying to redirect to a diff page depending on a certain condition,only one condition is working.the code is below.
<%@page import="java.sql.*;"%><%--import the sql pacakage of JAVA.--%>
<%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//Database Driver.
//Getting Data from HTML page.
String User=request.getParameter("UserName");
String Pwd=request.getParameter("Pwd");
Connection conn=DriverManager.getConnection("jdbc:odbc:File");
//Create a mysql odbc connection.
Statement st=conn.createStatement();//create a connection statement.
ResultSet res = st.executeQuery("SELECT * FROM users WHERE User_Name='"+User+"' AND Pwd='"+Pwd+"'");//create resultset to access data from database.
if(res!=null)
{
String redirectURL = "DeptInfo.html";//only this works
response.sendRedirect(redirectURL);
}
else//not working
{
String redirectURL = "Login.html";
response.sendRedirect(redirectURL);
}
res.close();//close resultset.
conn.close();//close connection.
%>
can any one tell me y this happens?
2006-09-01
20:30:14
·
1 answers
·
asked by
Niru
1
in
Computers & Internet
➔ Programming & Design