JSP problem

I deployed it through deployment tool 8.2 and put it in docroot ..

Both of there holding the same error...

error:

1

[javac]BankAccount BA =null;

[javac]^

2

[javac] BA = (BankAccount) _jspx_page_context.getAttribute("BA", PageContext.APPLICATION_SCOPE);

[javac]^

3

[javac]BA =new BankAccount();

[javac]^

[javac] 3 errors

Woud anybody know where is the problem...

I compiled the bankaccount.java and put it in the classes inside lib is it any path to be set...(docroot)

This is the main interface of my program

//filename : Usebeanexample.jsp

<html>

<head><title>User Validation</title></head>

<body bgcolor ="#fffffr">

<form method ="post" action ="Usebean.jsp">

<table border ="0" cellspacing ="1" cellpadding="5">

<tr>

<td width ="100"> </td>

<td align ="right"><h1><font color ="red">Welcome to Earnest bank</font></h1></td>

</tr>

<tr>

<td width ="100" align ="right"><b><font color ="blue">Account ID:</font></b></td>

<td align ="left"><input type ="text" name ="sAccountId" size ="30"></td>

</tr>

<tr>

<td width ="100" align ="right"><b><font color ="blue">Pin number</font></b></td>

<td align ="left"><input type ="password" name ="sPin" size ="30"></td>

</tr>

<tr>

<td width ="100"> </td>

<td align ="right"></td>

</tr>

<tr>

<td width ="100"> </td>

<td align ="left"><input type ="submit" value ="submit"></td>

</tr>

</table>

</form>

</body>

</html>

Bean class

//filename Usebean.jsp

<%@ page language ="java" %>

<jsp:useBean id ="BA" scope ="application"class ="BankAccount" />

<jsp:setProperty name ="BA" property ="sAccountID" param ="sAccountID" />

<jsp:setProperty name ="BA" property ="sPin" param ="sPin" />

<html>

<head><title>TITLE</title></head>

<body>

<%

String sAccountID = BA.getsAccountID();

String sPin = BA.getsPin();

boolean validate = BA.AccountValidate();

if(validate ==true)

{

out.println("The user is validated");

}

else

{

out.println("The user is not valid");

}

%>

</body>

</html>

java

//BankAccount.java

import java.io.*;

import java.sql.*;

publicclass BankAccount

{

private String sAccountID =" ";

private String sPin =" ";

Connection connect =null;

Statement state =null;

ResultSet result =null;

publicvoid setsAccountID(String sAccountID)

{

this.sAccountID = sAccountID;

}

publicvoid setsPin(String sPin)

{

this.sPin = sPin;

}

public String getsAccountID()

{

return sAccountID;

}

public String getsPin()

{

return sPin;

}

public BankAccount()throws ClassNotFoundException

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

publicboolean AccountValidate()

{

boolean validate =false;

String sPinNo="";

try

{

sAccountID = getsAccountID();

sPin = getsPin();

connect = DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","");

String strQuery ="select cPin_no from login where cAccount_id = '"+sAccountID+"'";

state = connect.createStatement();

ResultSet result = state.executeQuery(strQuery);

while(result.next())

{

sPinNo = result.getString(1);

}

sPinNo = sPinNo.trim();

sPin = sPin.trim();

if(sPinNo.equals(sPin))

{

validate =true;

}

}

catch(Exception e)

{

}

return validate;

}

}

[7284 byte] By [Reona] at [2007-11-27 10:59:21]
# 1

I think you'll have to import the class

In useBean.jsp, put in the top

<%@page import="yourpackage.BackAccount"%>

Manuel Leiria

manuel.leiriaa at 2007-7-29 12:22:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Looks like another tutorial that needs updating.

To use a class as a bean in a JSP it MUST be in a package.

All your classes should be in packages anyway.

- Put your bean in a package

package bank;

import java.io.*;

import java.sql.*;

public class BankAccount

{

-Recompile it and deploy it to your web app (should be WEB-INF/classes/bank/BankAccount.class)

- Use the fully qualified name when importing it with the useBean tag

<jsp:useBean id = "BA" scope ="application" class ="bank.BankAccount" />

Is BA meant to be in application scope? Everyone accessing the web application will use the same BankAccount object.

evnafetsa at 2007-7-29 12:22:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Thanx !! Thanx !! Thanx !! evnafets ...

I am holding this same problem for more than a weak..

Anyway i really appreciate you....and thanking you again ...

Thanx to you manuel.leiria ,you tried to help me...

manuel.leiria, but the answer is as said by evnafets...

Reona at 2007-7-29 12:22:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...