• Post Reply Bookmark Topic Watch Topic
  • New Topic

The value for the useBean class attribute is invalid.

sreedhar reddy
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.*;
import java.io.*;

public class DbBean1 implements Serializable {

String dbURL = "jdbc:sqlserver://dynproserver;database=EssentialFeed;user=sa;password=sa321";
String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
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="java.io.*"%>
<%@ 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
Posts: 65530
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you put the class file for the bean?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!