I'm using JSP for my dynamic web page and i am working on the login screen so that when an invalid user logs in the go directly to the error page but when a registered user logs in they go to the first page which is called irishshareprices.jsp. The problem is that no matter if it's a registered user or not it's automatically going to the indexerror.jsp page.
The following is the code i'm using:
<%-- Import required Java Classes --%>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%
String user = request.getParameter("username");
String pass = request.getParameter("password");
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
/*if ((user == null)||(pass == null))
{
response.sendRedirect("indexerror.jsp");
}*/
String queryText="SELECT * FROM User WHERE UserID = '" + user + "' AND Password = '" + pass +"'";
try {
//initialize the JDBC-ODBC bridge driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//open a connection to the database
String username = "";
String password = "";
con = DriverManager.getConnection("jdbc

dbc:db",username,password);
//execute the query
stmt = con.createStatement();
rs = stmt.executeQuery(queryText);
} catch (Exception e) { }
if ((user == rs.getString("UserID")) && (pass == rs.getString("Password")))
{
response.sendRedirect("irishshareprices.jsp");
}
else
{
response.sendRedirect("indexerror.jsp");
}
%>