Hi

JWS 2.0 beta2
Windows NT SP-4

Background.
==========

1. login.html contains user name & password text fields.
2. In this page i'm calling jdbcbean.jsp (inputs to this page are login
& password entered in html page)
3. jdbcbean.jsp will inturn call JDBCBean.java which is actually a bean

When i execute this JDBCBean.java as a standalone program, it works fine

and based on the inputs provided it returns either "fail" or "success"

But when i do the same in the
browser(i.e.http://localhost:8080/src/login.html)

i'm getting the following error message

Error during JSP page parsing

Unknown exception: java.lang.NullPointerException

I don't know where from i'm getting this error message.

Attached are login.html, jdbcbean.jsp & JDBCBean.java

------------------------------------login.html------------------------
In submit button i 'm calling jdbcbean.jsp
like <form method=get action=jdbcbean.jsp>
</form>

----------------------------------------------------------------------
----------------------------------jdbcbean.jsp------------------------


<usebean id=jdbc scope=request class=sunexamples.beans.JDBCBean />

String name=null;
String pass = null;
String err = null;
name = request.parameter(login_name);
pass = request.parameter(login_pass);

jdbc.setProps(name,pass)
err = jdbc.getProps( );

out.println(err);

----------------------------------------------------------------------
----------------------------------------JDBCBean.java-----------------

package sunexamples.beans;

import java.sql.*;
import java.util.*;

public class JDBCBean {

  static {
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch(ClassNotFoundException cnfe) {
      cnfe.printStackTrace();
    }
  }                                     // end static block


    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String url = "jdbc:odbc:TX01";
    String username="scott";
    String password="tiger";
    Hashtable ht = new Hashtable();
    String LoginName;
    String Password;

  public static void main (String args[]) {

    JDBCBean bean = new JDBCBean();
  //bean.setProps("kumar","swamy");
  //System.out.println(bean.getProps());

  }                                     // end main

    public void processRequest() {                 // start constructor

      try {

      con=DriverManager.getConnection(url, username, password);
      stmt = con.createStatement();
      rs = stmt.executeQuery("select * from LOGIN");
      String usr_login;
      String usr_password;

          while(rs.next()) {

            usr_login = rs.getString(1);
            usr_password = rs.getString(2);
            ht.put(usr_login, usr_password);
          }
      }                                 // end try

      catch(SQLException sqle) {
        sqle.printStackTrace();
      } // end catch block

  finally {

    try {
    if(con != null) con.close();
    if(stmt != null) stmt.close();
    if(rs != null) rs.close();
    } //end try in finally block

    catch(SQLException sqle) {
      sqle.printStackTrace();
    } //end catch in finally block

  } // end finally block

    }


  public void setProps(String _login, String _passwd) {

    LoginName = _login;
    Password = _passwd;
      }

  public String getProps() {
                System.out.println("Entered in getProps");
    if(ht.get(LoginName).equals(Password))

    return "Success";
    else
    return "Fail";

  }


} // finish class JDBCBean

----------------------------------------------------------------------

Am i doing something wrong here, pls let me know..

Thanks
Kumarswamy

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to