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 July 11th, 2003, 11:50 PM
Registered User
Join Date: Jul 2003
Location: colchester, essex, United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default JSP and LOGIN

Anyone could help me how can i create a login page by jsp....
it need to check username = password from database
 if u forget password it remind you your secret question and answer...THANKS

Reply With Quote
  #2 (permalink)  
Old April 28th, 2005, 01:35 AM
Registered User
Join Date: Feb 2005
Location: ShangHai, , China.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

String username=request.getParameter("username");
String userpass=request.getParameter("userpass");
String DBDriver="jdbc:odbc:driver={Micosoft Access Driver(*.mdb)";
    Connection conn=null;
    Statement comm=conn.createStatement();
    String strSQL = "select * from member where username='"+username+"' and userpass='"+userpass+"'";
    ResultSet Res=comm.executeQuery();
        out.println("<script>alert('error information');</script>");
}catch(Exception ex){

Reply With Quote
  #3 (permalink)  
Old April 29th, 2005, 12:08 AM
Authorized User
Join Date: Mar 2005
Location: Pune, Maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dadahonde Send a message via Yahoo to dadahonde

Hello You are right on the way.
Except following is the little mistake i noticed in the piece of code you prepared.
For reference your statement is :
      ResultSet Res=comm.executeQuery();
You need to pass the parameter which is a SQL query(String) to the executeQuery() method.

so the statement would become as :
     ResultSet Res=comm.executeQuery(strSQL);

Dadasaheb T. Honde

Reply With Quote
  #4 (permalink)  
Old November 30th, 2005, 04:11 AM
Authorized User
Join Date: Nov 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

i have modify the code that peter huang wrote and try to run .. but erro occur .. can anyone helps me?

<%@ page import="java.sql.*" %>

    String adminId = request.getParameter("admin_id");
    String adminPassword = request.getParameter("admin_password");
    String driver = "jdbc:mysql.jdbc.Driver";
    String url = "jdbc:mysql://localhost:3306/sers";
    String username = "root";
    String password = "123";
    String query = "SELECT admin_id,admin_password FROM admin WHERE admin_id = '"+adminId+"' AND admin_password = '"+adminPassword+"'";
    Connection con = null;
    Statement statement = null;
    ResultSet rs = null;

        con = DriverManager.getConnection(url,username,password) ;
        statement = con.createStatement();
        rs = statement.executeQuery(query);
            out.println("<h1>Login Fail</h2>");
            out.println("<h1>welcome" + "!</h1>");
    catch(Exception ex)
        out.println("Error: " + ex.getMessage());

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
Help! JSP Login yikchin JSP Basics 1 December 8th, 2005 02:35 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:42 PM.

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