ok here it goes again. my code is shown below:
<%@ page import="java.sql.*,java.io.*" %>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
Connection con = null;
Statement stmt = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc
dbc:malldata");
String sql = "SELECT CUST_ID,USER_ID, PASSWORD FROM CUSTMASTER WHERE USER_ID=? and PASSWORD=?";
ps = con.prepareStatement(sql);
stmt = con.createStatement();
ps.setString(1,username);
ps.setString(2,password);
rs = ps.executeQuery();
if (rs.next()) {
out.println (rs.getObject(1).toString());
out.println (rs.getObject(2).toString());
out.println (rs.getObject(3).toString());
}
else %>
<jsp:forward page="login.html" />
<% } catch (SQLException e) {
throw new ServletException ("servlet could not display records . " + e);
}
catch (ClassNotFoundException e) {
throw new ServletException ("Jdbc driver not found " + e);
}
finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (stmt != null) {
stmt.close();
stmt = null;
}
if ( con != null) {
con.close();
con = null;
}
} catch (SQLException e) {}
} // close of finally
%>
ok i have attached my code. The jsp forward is called irrespective of the condition. In plain language i would like to know how to forward my control back to my html page because the above else loop functions even if the values are retrieved from the database.