Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JSP: Login Authentication

843838May 15 2006 — edited Sep 27 2006
Hi All,

I am trying with my below JSP code to validate the username and password which enter from my page by verifying with the username and password in Microsoft Access database.

I never get any error alert with that code, but i also get blank on my page instead.

The code are below:
<html>
<head>
<title>Welcome to the online Auction...</title></head>
<body>

<%@ page language ="java" import = "java.io.*" import = "java.lang.*" import = "java.sql.*" %>

<% try

{

	String strUsername = request.getParameter("username"); 
	String strPassword = request.getParameter("password"); 
	
	Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); 
 
 	Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
 	
 	Statement myStatement = myConn.createStatement ();
 	
	String strSQL = "SELECT [UserName], [Password] FROM  tblUserDetails";
	

	ResultSet myResult = myStatement.executeQuery(strSQL);
	
	String strUser = myResult.getString("UserName");
	String strPass = myResult.getString("Password");
	
	while(myResult.next())
    
    {
	
	if(strUsername.equals(strUser) && strPassword.equals(strPass))
	
                {
                    out.println("Login Successful!");
                }
                else
                {
                    out.println("Login Fail!");
                }
	
	}	
		
	myConn.close();
}
	catch(Exception e){} 
%>
			
</body> 
</html>
Could you please advise what is the problems?

Kimsan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2006
Added on May 15 2006
6 comments
557 views