Java-JSP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Java-JSP

Hi

I am doing a project called login authentication is required, here is my code:

main.jsp



Nouman Rashid page



Please enter your user name and
password






username


password










process.jsp
<%@ page import="java.util.*" %>




<%
if (idHandler.validate()) {
%>

<%
} else {
%>

<%
}
%>

Login.java

package foo;
import java.sql.*;

public class Login {

private String username = "";
private String password = "";

public Login() {
}

public void setUsername(String username) {
this.username = username;
}

public void setPassword(String password) {
this.password = password;
}


public boolean authenticate(String username2,
String password2) {
String query="select * from Registration;";
String DbUserName="";
String DbPassword="";
String finalUser="";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:register");
Statement stat=con.createStatement();
ResultSet rst=stat.executeQuery(query);
while(rst.next())

{
DbUserName=rst.getString("UserName");

DbPassword=rst.getString("password");

if (username2.equals(DbUserName) &&
password2.equals(DbPassword)) {

break;
}


}
return true;
}catch(Exception e){

e.printStackTrace();
return false;
}
}}


success.jsp




JSP Page

Login Successful




retry.jsp



JSP Page

Retry Please





Now am always getting the retry page when i key in the username and password which are stored in the database.

Please help me to solve this problem, reply soon its urgent




Sign In or Register to comment.