Wrox Programmer Forums
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 12th, 2008, 05:11 AM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login Page

Hiii...
i have been workin on the login page..i have to take the username n password as input n check it frm d data base...
m using the ms access data base...
i have to do the server side validations...
but i am unable to do the validations..
here's my code...



<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ page import="java.sql.DriverManager"%>
<%@page import="java.sql.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
    String Username = "";
    String Password = "", pass = "";

    Username = request.getParameter("userName");
    Password = request.getParameter("passWord");

    try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        // set this to a MS Access DB you have on your machine
        String filename = "test.mdb";
        String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
        database += filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
        // now we can get the connection from the DriverManager
        Connection con = DriverManager.getConnection(database, "", "");

        Statement stmt = con.createStatement();
        ResultSet rs = stmt
                .executeQuery("select password from login WHERE username = '"
                        + Username + "'");
        //s.execute("select username,password from test");
        //ResultSet rs = s.getResultSet();

        while (rs.next()) {
            pass = rs.getString(1);
            out.print(pass);
            if (Password.equals(pass)) {
                out.print("Welcome" + Username);
            } else {
                out.print("Sorry");
            }
        }


        stmt.close();
    } catch (Exception e) {
        System.out.println("Error: " + e);
    }
%>
</body>
</html>


i am nt able to print the Welcome message...
every time its going into the else loop...

plz have a look on this issue..thnx...


Deepak
 
Old May 12th, 2008, 06:41 AM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey guys...
i got d solution for my ques...
thank u for lookin into it...

Deepak





Similar Threads
Thread Thread Starter Forum Replies Last Post
login page abaso.jadhav01 ASP.NET 2.0 Basics 3 February 3rd, 2007 05:05 AM
Login Page ninel General .NET 0 November 2nd, 2006 11:40 AM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 07:09 PM
LOGIN PAGE (does not link to the next page) [email protected] Classic ASP Databases 7 April 5th, 2006 01:28 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.