|
Thanks for your assistant and may God bless you all Amen.
Login.html page is what user use to login which, will take him to validateform.jsp page, inorder to check if the user is a register user to have access to the page. Then, the UsePage.jsp is a welcome page that's, if successfully. But the error that i encounter after using Deploytool is
HTTP STATUS 500
javax.servlet.ServletException: Column not found
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:830)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:763)
org.apache.jsp.ValidateForm_jsp._jspService(ValidateForm_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
PLEASE REPLY KELLY(NIIT Student). Remain Bless All Developers Amen.
snookcent@yahoo.com, iykelly4love@yahoo.co.uk
My table name is Registration.
Columns are DbUserName and DbPassword.
Login.html (Login Page)
<html>
<head><title>Please Sign in</title></head>
<h2>Please Login</h2>
<body>
<form method="post" action="http://localhost:8080/valid/ValidateForm.jsp">
<tr>
<td>UserName:</td>
<td><input type="text" name="username"></td>
</tr><br>
<tr>
<td>password:</td>
<td><input type="password" name="password"></td>
</tr><br>
<tr>
<td><input type="submit" value="Login"></td>
</tr>
</form>
</body>
</html>
ValidateForm.jsp
<html>
<head>
<title>login validator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<body>
<%
Connection con = null;
String username = request.getParameter("username");
String password = request.getParameter("password");
String DbPassword = "";
String DbUserName="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:KellySource", "java", "javaclass");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from Registration");
while(rs.next())
{
DbUserName=rs.getString(username);
DbPassword = rs.getString(password);
}
if (username.equals(DbUserName) && password.equals(DbPassword))
{
}
else
{
}
}
finally
{
con.close();
}
response.sendRedirect("/forum/UsePage.html");
%>
</body>
</html>
UsePage.jsp
<html>
<head><title>You have Successfully Login</title></head>
<body bgcolor=bluelight>
<h2>You have Successfully Login</h2>
</body>
</html>
|
|
|
Problem is here..
DbUserName=rs.getString(username);
DbPassword = rs.getString(password);
replace it with
DbUserName=rs.getString(1);
DbPassword = rs.getString(2);
Or
DbUserName=rs.getString("DbUserName");
DbPassword = rs.getString("DbPassword");
----------------------------------------
The code should be actually
String username = request.getParameter("username");
String password = request.getParameter("password");
while(rs.next()) {
DbUserName=rs.getString(1);
DbPassword = rs.getString(2);
if (username.equals(DbUserName) && password.equals(DbPassword)) {
}
else {
}
}
|
|
|
|
|
|
|
// |