Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error:The value for the useBean class attribute JBean is invalid  RSS feed

 
timsy upmon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i m getting this error The value for the useBean class attribute JBean is invalid.

while calling jsp page through tomcat

my java file is

import java.sql.*;

class JBean
{

public JBean()
{
}
public static void main(String s[]) throws
SQLException,ClassNotFoundException
{

String StNo,StFName,StLName,Stout;
Connection Conn;
Statement Stmt;
ResultSet rs;

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

Conn=DriverManager.getConnection("jdbc dbc:stuDB","uname","pw");
Stmt=Conn.createStatement();
rs=Stmt.executeQuery("Select StNo,StFName,StLName FROM Student");


while(rs.next())

{

StNo=rs.getString(1);
StFName=rs.getString(2);
StLName=rs.getString(3);
Stout=(String)(StNo+" "+StFName+" "+StLName);
System.out.println(Stout);
//System.out.println(StNo+" "+StFName+" "+StLName);
}
}
}

n jsp file is

<html>
<head>
<title>
PHI Employees Time Record
</title>
</head>
<font color=#DB1260>

</font>


<h2> PHI EMPLOYEE ASSIGNMENT RECORD</h2>

<body bgcolor=="#Fc99FF">
<font color=#DB1260>

</font>

<%@page language= "java" %>

<jsp:useBean id="JBean" class="JBean" scope="application" />.

<jsp:getProperty name="JBean" property="Stout" />


</body>
</html>

i have saved the class file in

C:\tomcat\webapps\ROOT\WEB-INF\classes

pls any one can help me wat could be the reason
[ September 28, 2005: Message edited by: Bear Bibeault ]
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bean class has to be in a package.

cheers,
ram.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, i dint quite complete the earlier post.

1. The class has to be in a package.



2. The class file has to be placed in

WEB-INF/classes/com/mybean/JBean.class

3. Use the fully qualified class name in the class attribute of the useBean tag



cheers,
ram.
 
Vipul Shinde
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The variables that u have declared in main() of bean class should be declared as member variables of bean class. Use should have set & get methods implemented in bean class for each of the memnber variables.

Do not use main() in bean class. Bean class should just contain the set & get methods. The set & get methods for a particular member variable r called when a setproperty or getproperty tags occurs on the jsp page.

Vipul
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally quoted by Vipul
--------------------------
The variables that u have declared in main() of bean class should be declared as member variables of bean class. Use should have set & get methods implemented in bean class for each of the memnber variables.

Do not use main() in bean class. Bean class should just contain the set & get methods. The set & get methods for a particular member variable r called when a setproperty or getproperty tags occurs on the jsp page.



Quite correct, that's the way you will get it to work eventually. However that's not the cause of the error.

cheers,
ram.
 
timsy upmon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx alot but both the solutions have not worked

i've created a new java file

public class trybean
{
String Stout;



public void setout()
{
Stout="hjkuiytrf";
}

public String getout()
{
return Stout;
}
}

n jsp file is
<html>
<head>
<title>
PHI Employees Time Record
</title>
</head>
<font color=#DB1260>

</font>


<h2> PHI EMPLOYEE ASSIGNMENT RECORD</h2>

<body bgcolor=="#Fc99FF">
<font color=#DB1260>

</font>

<%@page language= "java" %>

<jsp:useBean id="try" class="trybean" scope="application" />.

<jsp:getProperty name="try" property="out" />


</body>
</html>
n saved the class file at

C:\Tomcat 5.5\webapps\ROOT\WEB-INF\classes

n set the classpath also

but it is still giving the same error
/prjphi1.jsp(21,0) The value for the useBean class attribute trybean is invalid.
i tried with classpath also

please help me where i m going wrong
doesn't work in pkg also
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!