File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes The value for the useBean class attribute is invalid. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "The value for the useBean class attribute is invalid." Watch "The value for the useBean class attribute is invalid." New topic

The value for the useBean class attribute is invalid.

sreedhar reddy

Joined: Jul 20, 2006
Posts: 1

i am trying to access bean class properties into jsp, but it is showing following exception when i execute my .jsp file.

org.apache.jasper.JasperException: /Essential2/DBConnection3.jsp(6,0) The value for the useBean class attribute beans.DbBean1 is invalid.

--------- Bean class--------
package beans;

import java.sql.*;

public class DbBean1 implements Serializable {

String dbURL = "jdbc:sqlserver://dynproserver;database=EssentialFeed;user=sa;password=sa321";
String dbDriver = "";
Connection dbCon;

public DbBean1(){


public boolean connect() throws ClassNotFoundException,SQLException{
dbCon = DriverManager.getConnection(dbURL);

return true;

public Connection getConnection() throws ClassNotFoundException,SQLException{
return dbCon;

public void close() throws SQLException{

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;


--------------.jsp file---------------------------------
<%@ page import="java.lang.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="*"%>
<%@ page import="java.util.*"%>
<%@ page contentType="text/html" %>
<jsp:useBean id="db1" class="beans.DbBean1" scope="request"/>

String uid = " ";

String userid = (String)session.getAttribute("uid");
//Submit New Feed Information
String s1=request.getParameter("podcastname1");
String s2=request.getParameter("feeddescription1");
String s3=request.getParameter("category1");
String s4=request.getParameter("subcategory1");
String s5=request.getParameter("subfrequency1");
String s6=request.getParameter("subfee1");
String s7=request.getParameter("contentrating1");
String s8=request.getParameter("keywords1");
String s9=request.getParameter("logopath1");
//String s9b= "C:/";
//String s9 = s9b + s9a;

String s10=request.getParameter("submitmyfeed1");
System.out.println(s1+" *"+s2+" *"+s3+" *"+s4+" *"+s5+" *"+s6+" "+s7+" *"+s8+" *"+s9+" *"+s10);

// String connectionUrl = "jdbc:sqlserver://dynproserver;database=EssentialFeed;user=sa;password=sa321";
//Connection connection = DriverManager.getConnection(connectionUrl);

//Statement st1 = connection.createStatement();
//ResultSet rs1 = st1.executeQuery("select User_ObjId from User_Info where Email_Address = '"+userid+"'");

ResultSet rs1 = db1.execSQL("select User_ObjId from User_Info where Email_Address = '"+userid+"'");
uid = rs1.getString(1);

String str4 = "insert into Podcast_Info(Podcast_Name, FeedDescription, Category, Sub_Category, Subscription_Frequency, Subscription_Fee, Content_Rating, Keywords, LogoPath, SubmitMyFeed, User_ObjId) values(?,?,?,?,?,?,?,?,?,?,?)";

PreparedStatement preparedstatement4 = db1.getConnection();
//PreparedStatement preparedstatement4 = connection.prepareStatement(str4);
preparedstatement4.setString(1, s1);
preparedstatement4.setString(2, s2);
preparedstatement4.setString(3, s3);
preparedstatement4.setString(4, s4);
preparedstatement4.setString(5, s5);
preparedstatement4.setString(6, s6);
preparedstatement4.setString(7, s7);
preparedstatement4.setString(8, s8);
preparedstatement4.setString(9, s9);
preparedstatement4.setString(10, s10);
preparedstatement4.setString(11, uid);

catch(Exception exception)
// System.out.println("database", "Error in connecting database! Please try again!");

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

Where did you put the class file for the bean?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: The value for the useBean class attribute is invalid.
jQuery in Action, 3rd edition