SignIn.html

--------------
<HTML><HEAD>
<TITLE>Log In To Your Account</TITLE>
</HEAD>
<BODY>
<H2><Bold>Log In To You Account</Bold></H2>
<p>To log in, type in your USERNAME and PASSWORD.
<br>Then click on the Submit button.</p>
<FORM ACTION="Sign.jsp" METHOD="POST">
<br>USERNAME:
<INPUT TYPE=TEXT NAME ="UserName">
<br>PASSWORD:
<INPUT TYPE=TEXT NAME ="Passwrd">
<br>
<INPUT TYPE=Submit VALUE ="Submit">
</FORM>
</BODY></HTML>

Sign.jsp

---------

<%@page import="java.sql.*"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@ page import = "myjsp.login" %>
<jsp:useBean id="cBean" scope="session" class="myjsp.login" />

<% 

String uname=request.getParameter("UserName");
String pwd=request.getParameter("Passwrd");

if(uname !=null && pwd !=null)
{

cBean.connectDb();
cBean.statementDb("SELECT AdminNo, Name,Address,Contact, School, Username, Password FROM Students");
String username= cBean.getUsername();
String password= cBean.getPassword();


if(uname.equalsIgnoreCase(username) && pwd.equalsIgnoreCase(password))
{

response.sendRedirect("Welcome.jsp");
}
else
{
}
}

cBean.closeDb();
}

%>

login.java

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

package myjsp;
import java.sql.*;
import java.util.*;
import java.io.*;

 public class login {

    Statement statement;
    Connection connection;
    ResultSet columns;


   private String Username = "";
 private String Password = "";



   public login() {}

   public void connectDb() throws ClassNotFoundException, SQLException
   {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection=DriverManager.getConnection("jdbc:odbc:books4u","","");
   }

   public ResultSet statementDb(String qy) throws SQLException
   {
    statement = connection.createStatement();
    columns=statement.executeQuery(qy);
    return columns;
   }

   public void closeDb() throws SQLException
   {
    columns.close();
    statement.close();
    connection.close();
   }

public String getUsername()
{
return Username;
}

public String getPassword()
{
return Password;
}

  public void setUsername(String uname) {
     Username = uname;
  }

  public void setPassword(String pwd) {
     Password = pwd;
   }
   }

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

Sorry if my codes seem so stupid. I am as beginner as it gets. I've tried doing the login page using just the html and jsp alone and it works. But the project requires us to use javabeans to make the login page. Can anyone help pls?

For my database i'm using MS access.

Thanks.

here's the errors i got:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 10 in the jsp file: /myjsp/EwapProjBean/Sign.jsp
Generated servlet error:
Syntax error, insert "Finally" to complete TryStatement

Generated servlet error:
Syntax error on token "catch", Identifier expected

Generated servlet error:
out cannot be resolved

Generated servlet error:
_jspx_out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
out cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Generated servlet error:
Syntax error on token "finally", { expected

Generated servlet error:
_jspxFactory cannot be resolved

Generated servlet error:
_jspxFactory cannot be resolved

Generated servlet error:
_jspx_page_context cannot be resolved

Read this it will help you understand where you went wrong

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.