Wrox Programmer Forums
| 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 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
  #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

  #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){

  #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

  #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());

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

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