I found some code on jspin.com, exactly what im looking for, I changed a few things around as it was not compiling properly, due to some errors, now Im at a stage were there are no errors but Im not forwarded to success or the retry page, sorry about the long code guys, I really hope some one can help, it will be greatly appreciated
<%@ page import="java.util.*" %>
<jsp:useBean id="idHandler" class="foo.Login" scope="request">
<jsp:setProperty name="idHandler" property="idHandler"/>
</jsp:useBean>
<%
String arg1=request.getParameter("username");
String arg2=request.getParameter("password");
%>
<%
String username1=idHandler.getUsername(arg1);
String password1=idHandler.getPassword(arg2);
%>
<%
if (idHandler.authenticate(username, password)) {
%>
<jsp:forward page="success.jsp"/>
<%
} else {
%>
<jsp:forward page="retry.jsp"/>
<%
}
%>
Process2 code is above
package foo;
import java.sql.*;
public class Login {
protected String username = "";
protected String password = "";
public Login() {
}
public void setUsername(String Username) {
username = this.username;
}
public void setPassword(String Password) {
password = this.password;
}
public String getUsername(String username){
return username;
}
public String getPassword(String password){
return password;
}
public boolean authenticate(String username,
String password) {
String query="select * from registration;";
String DbUserName="";
String DbPassword="";
try {
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "xxxxxx");
java.sql.PreparedStatement statement = connection.prepareStatement(query);
java.sql.ResultSet rst = statement.executeQuery();
while(rst.next())
{
DbUserName=rst.getString("UserName");
DbPassword=rst.getString("password");
if (username.equals(DbUserName) &&
password.equals(DbPassword))
{
break;
}
}
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}}
Javabean code above