This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Is my javaBean a javaBean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Is my javaBean a javaBean?" Watch "Is my javaBean a javaBean?" New topic
Author

Is my javaBean a javaBean?

Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
I'm sorry if I posted this in the wrong forum.

Here's my problem...
I have a javaBean that writes stuff to the database to be saved.
It works fine when I use a testing Class to invoke the bean's method to write some dummy variables.

When I deployed it on a JSP page, I received the following error.

"org.apache.jasper.JasperException: /checkout.jsp(4,0) The value for the useBean class attribute limited.InsertDataBean is invalid.
"

I should think my bean met the bean requirements. But I can't find out what's wrong. Any help would be really really really great..

Here's my insertDataBean code



Do you have a parka?<br /> <br /><a href="http://sg.geocities.com/inschooool" target="_blank" rel="nofollow">Visit my homepage</a> | <a href="http://parka.deviantart.com/" target="_blank" rel="nofollow">Parka Deviantart gallery</a>
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
There error you received has to do with the JSP syntax you used to import the bean, not a problem with the bean itself (Jasper's job is to turn JSP into java code, not to make sure you followed good programming practices while designing your bean)
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
Hi.

I have the following tags in my JSP.

<jsp:useBean id="cart" scope="session" class="limited.CartBean" />
<jsp:useBean id="idBean" scope="page" class="limited.GetOrderIDBean" />
<jsp:useBean id="databean" scope="page" class="limited.InsertDataBean" />

Only the third failed to compiled.



Nothing's looking wrong.....or is there...

Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
On further inspection, your default constructor isn't public and must be to be used with the useBean tag.
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
Hmmmm...

When I included the public infront of the empty constructor, it still couldn't work.

But when I deleted the constructor away, it's able to work again.

Oh my!! It works now!
 
Don't get me started about those stupid light bulbs.
 
subject: Is my javaBean a javaBean?
 
Similar Threads
doubt having servlet connect to oracle XE database
Resultset to flat file.
404 error. Can't find resource?
DATABASE OBJECT-- URGENT URGENT
insert to database...