wood burning stoves 2.0*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
Author

The value for the useBean class attribute is invalid.

sreedhar reddy
Greenhorn

Joined: Jul 20, 2006
Posts: 1
Hi,

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(){
super();

}

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

return true;
}


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



public void close() throws SQLException{
dbCon.close();
}

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 = " ";
%>

<%
try
{
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);

//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// 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+"'");
while(rs1.next())
{
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);
preparedstatement4.executeUpdate();

preparedstatement4.close();
connection.close();
}
catch(Exception exception)
{
exception.printStackTrace();
// System.out.println("database", "Error in connecting database! Please try again!");
}
%>
---------------------------------------------

Thanks
Sredhar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

Where did you put the class file for the bean?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: The value for the useBean class attribute is invalid.