jsp login using a access database

I am using NetBeans IDE 5.5.1 and I have a Login.jsp and a access database. How do i create a login from my jsp page that reads from my database?
<center>
              UserName
                <input type="text" name="ID" id="ID" />
                
                </form>
                <p>ID &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="password" name="Occupation" id="Occupation" />
</p>
 
  <input name="Login" type="button" id="Login" value="Login" />
  </center>

Open in new window

tdawg6Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mohammedfCommented:
here is a full working application
http://rapidshare.com/files/88611787/jhtp5.rar.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrcoffee365Commented:
Netbeans has good online documentation.  This page:
http://www.netbeans.org/kb/articles/security-webapps.html
walks you through the steps to create a form-based login for Tomcat (or Sun's Web app server).

You don't have to use the mechanism that comes with Tomcat, however.  You could  create a form and have users log in.  Then you could write your own code to keep the pages secure from non-logged in Web site visitors.  It's easier to use a login package, like the one that comes with Tomcat, but you don't have to.

If you are asking how to make a query to an Access db from a JSP, here is a simple example:

Connection con = null;
Statement stmt = null;
ResultSet rs = null;

try
{
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
      con = DriverManager.getConnection( "jdbc:odbc:MyDbName", dbUser, dbPassword );
      stmt = con.createStatement( );

      rs = stmt.executeQuery("Select Id, Field1 from Table 1");
      while( rs.next() ) {
            int recId = rs.getInt("Id");
            String field1 = rs.getString("Field1");
      }
}
catch( SQLException e ) {
      e.printStackTrace();
}

This uses the JDBC-ODBC driver to access your Access db.  You have to have an ODBC connection defined for your Access db (as a System DSN), which in this example is named MyDbName.  Access dbs often don't have usernames and passwords.  If you don't, you can leave off the dbUser and dbPassword parameters to the getConnection call.
0
pronaneCommented:
rose india does a nice app for you, if you replace the code in the checkValidUser to do a sql select on your DB it will work a treat:

http://www.roseindia.net/jsf/IntegratingLogin_Registration.shtml

ResultSet rs = stmt.executeQuery("select name * from userTable where userId ='1'");

if(rs = null)
           user does not exist
else
      user exists
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.