codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Validaing User Id using JSP and Servlet  jkelly at 14:02 on Friday, June 08, 2007
 

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>



  Re: Validaing User Id using JSP and Servlet  kanad at 13:31 on Wednesday, June 13, 2007
 

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 {

}

}








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Code triggered using Workbook_Open event reopens excel even after closing
•  asp.net n access database
•  Re: hi there, a do while loop needs work
•  reading and sending a msg through tcp socket
•  SEAMONKEY-onfocus
•  Cursor position line number in firefox.
•  oops perl
•  Validaing User Id using JSP and Servlet
•  IMPLEMENT JAVABEANS IN JSP


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007