Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2005, 03:10 AM
Authorized User
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help! JSP Login

I have create a jsp called admin_validate.jsp, when i key in the admin id and admin password, the admin_validate will check the database and print a proporiate messages. the problem is it will check one by one and wont stop until the end of record and print out message one by one. How to solve the problem? thank you very much

[u]this is the admin_validate.jsp code:</u>
<%@ page import="java.sql.*" %>

    String driver = "com.mysql.jdbc.Driver";
    String url = "jdbc:mysql://localhost:3306/sers";
    String username = "root";
    String SQLPassword = "123";
    Connection con = null;
    Statement statement = null;
    ResultSet rs = null;

        <title>Administrator Authentication</title>
            con = DriverManager.getConnection(url,username,SQLPasswo rd);
            statement = con.createStatement();
            rs = statement.executeQuery("SELECT admin_id,admin_password FROM admin");

                String DbAdminId = rs.getString("admin_id");
                String DbAdminPw = rs.getString("admin_password");
                String idValidate = request.getParameter("userid");
                String pwValidate = request.getParameter("password");

                if(idValidate.equals(DbAdminId) && pwValidate.equals(DbAdminPw))
                    out.println("<h1 align=center>" + "Login Successful!" + "</h1>");
                    out.println("<h1 align=center>" + "Login Fail!" + "</h1>");

Reply With Quote
  #2 (permalink)  
Old December 8th, 2005, 02:35 AM
Registered User
Join Date: Nov 2005
Location: Bombay, Maharashtra, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to bytepower

Use this instead of your code -


String sql = "select * from admin where username='"+postusername+"' and password='"+postpassward+"'";

Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);


Arvind Jagtap,
Software Engineer,Bombay
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP and LOGIN cbolat JSP Basics 3 November 30th, 2005 04:11 AM
jsp login page ronnie JSP Basics 4 April 12th, 2005 11:45 PM
jsp & mysql login code sos jaymak121 Java Databases 4 November 25th, 2004 06:50 AM
Help with jsp login page javaStudent JSP Basics 0 January 27th, 2004 06:08 PM

All times are GMT -4. The time now is 06:29 PM.

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