Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
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 March 27th, 2005, 06:04 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default login check urgent

I am facing some problems while checking the login for a particular user in my project...I m pasting my code..can someone please correct it if they can spot the error..

************************************************** *******************
<html>
<head>
<title>JDBC Connection </title>
</head>
<body>

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

<%
    Connection conn = null;
        ResultSet rs=null;
    String name=new String();
    String passwd=new String();


        try
    {
        Class.forName("oracle.jdbc.driver.OracleDriver");
              conn = DriverManager.getConnection("jdbc:oracle:thin:@10. 100.56.16:1521:btech9", "200412042", "ans");

              Statement stmt = conn.createStatement();
              rs = stmt.executeQuery("select username,password from ch where username='"+request.getParameter("nm") + "' AND password=PASSWORD('"+request.getParameter("pwd")+" ')");

        while(rs.next())
        {
            name=rs.getParameter(nm);
            passwd=rs.getString(pwd);
        }
        if(nm.equals(name))
        {
            if(pwd.equals(passwd))
            {
                out.println("Login successful");
            }
        }
        else
            out.println("login denied");
     }

    catch(SQLException e)
       {
           System.out.println("SQLException: " + e.getMessage());
       }

    catch(ClassNotFoundException e)
    {
        System.out.println("ClassNotFoundException: " + e.getMessage());
    }

    finally
    {
          if(conn != null)
          {
             try
             {
                conn.close();
             }
             catch (Exception ignored) {}
    }
   }
%>


</body>
</html>


************************************************** *******************

ERROR:------->>>

D:\Apache Tomcat 4.0\work\localhost\_\ans\ex$jsp.java:85: Undefined variable: nm
                            name=rs.getParameter(nm);
                                                 ^


ans4u
 
Old March 27th, 2005, 07:57 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i m done with this...so no need to reply on this post...thnx!!

ans4u
 
Old March 31st, 2005, 07:37 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to VIkas_Malik
Default

actually ur using the name of the record-set rs and give the form object names
so try to run following code
 name=rs.getParameter(username);
 passwd=rs.getString(password);

it will work
ok bye


Vikas Malik





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent help - Customized Windows login Screen Rehanrana Visual C++ 1 December 27th, 2007 03:48 AM
Urgent help - Customized Windows login Rehanrana C++ Programming 0 December 26th, 2007 08:15 AM
Shading on remember me check box and login backgou mmmctigue BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 July 20th, 2007 09:10 PM
Error: Login failed for user sa -urgent hums ADO.NET 5 September 28th, 2004 05:52 AM
Urgent : Getting Error :Login failed for user sa hums SQL Server ASP 1 September 28th, 2004 05:51 AM





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