Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ID Verification using JSP

807597Oct 26 2005 — edited Oct 27 2005
I got this code for ID validation using JSP...I have some problem though..I am posting the codes below, have a look at the codes than my problem description...

MAIN.JSP:
----------

<html>
<head>
<title>Nouman Rashid page </title>
</head>

<body>
<br>
<p> <h3><center>Please enter your user name and
password</center></h3></p>

<br>
<br>
<form action="process2.jsp " method = "post" >
<center>username</center>
<center><input type = "text" name=
"username"></center>
<center>password</center>
<center><input type = "password" name =
"password"></center>
<center><input type="submit" name="Submit"
value="Login"></center>


</form>

</body>
</html>

---------------


process2.jsp
---------------

<%@ page import="java.util.*" %>
<jsp:useBean id="idHandler" class="foo.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>

<%
if (idHandler.authenticate()) {
%>
<jsp:forward page="success.jsp"/>
<%
} else {
%>
<jsp:forward page="retry.jsp"/>
<%
}
%>
---------------------

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;
}
}}
---------------------------------

Now..the problem is this ...I am getting this error when I compile the process2.jsp file... " authenticate in foo.Login cannot be applied to () if(idHandler.authenticate() ) ) { "

can someone shed some light on this...by the way the IDE i am using is NetBeans.

I hope someone can help...thanks!!!

regards
JavaMan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2005
Added on Oct 26 2005
6 comments
95 views