Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login validation problem

Status
Not open for further replies.

pjdas

Programmer
Feb 24, 2003
5
US
I'm trying to do login validation from my jsp page. I have two jsp page. One login.jsp which create login form and second is validation.jsp..which should check username and password to database table, to make sure that username and password exit.And if it does it should send user to other page,or if it doesnt then send to error page. so how im missing something in my validation.jsp. i cant seems to figure it out.
Here is my validation.jsp code

<html>
<head>
<title>store data in database</title>
</head>
<%@ page import=&quot;java.sql.*&quot; %>
<body>

<%
String userName=request.getParameter(&quot;userName&quot;);
String secretWord=request.getParameter(&quot;secretWord&quot;);
%>

<%
String connURL = &quot;jdbc:eek:racle:thin:mad:orca.csc.ncsu.edu:1521:ORCL&quot;;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;).newInstance();
conn = DriverManager.getConnection(connURL, &quot;vapatel&quot;,&quot;pjdas&quot;);
stmt = conn.createStatement();


String sqlStatement = &quot;SELECT * FROM Login WHERE Username = '&quot;+userName+&quot;' AND Password='&quot;+secretWord+&quot;'&quot; ; stmt.executeUpdate(sqlStatement);
stmt.close();

} catch (ClassNotFoundException e) {
System.err.println(&quot;Couldn't find the mm &quot; + &quot;database driver: &quot;
+ e.getMessage());
} catch (InstantiationException e) {
System.err.println(e.getMessage());
} catch (IllegalAccessException e) {
System.err.println(e.getMessage());
} catch (SQLException e) {
System.err.println(&quot;SQL problem: &quot; + e.getMessage());
System.err.println(&quot;SQL state: &quot; + e.getSQLState());
System.err.println(&quot;Vendor error: &quot; + e.getErrorCode());
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
System.err.println(e.getMessage());
}
}



%>

<h2> Thank You</h2>
The Database has been updated.
</body>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top