This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSP and the fly likes use of bean in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "use of bean in jsp" Watch "use of bean in jsp" New topic

use of bean in jsp

abhishek paliwal

Joined: Jun 25, 2005
Posts: 4
i am facing a problum in using java bean in jsp.
i am sending the sample code here.
bean is:
package op;
class exam
String name;
public void setname(String r)
public String getname()
return name;
this file is stored in my application's WEB-INF's classes's op folder.
i am using bean in jsp as
<jsp:useBean id="db" class="op.exam" scope="request"/>
but this gives the error "The value for the useBean class attribute 'op.exam' is invalid."
please help me.
Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
A Simple clue would be just restart the Server and check again !!!

Only those who will risk going too far can possibly find out how far one can go !!!
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

A couple things:

1.) When posting more than a line or two of your code, wrap the code in a set of UBB Code tags. This will preserve your indenting and make your code much easier to read (usually resulting in more people reading it and, thus, more help).

2.) Use the standard Java naming/capitalization conventions.
Class names should start with a capital letter. Object variables for those classes should be spelled the same but start with a lower case letter. This makes it very easy for people reading your code to understand the difference between the two.

When you say "this file" is stored under WEB-INF/classes/op, what file do you mean? A source file (.java) or did you compile the bean class and put the .class file there?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stefan Evans

Joined: Jul 06, 2005
Posts: 1518
To qualify as a bean, your class must have a public constructor that takes no arguments.


make your class public
make the constructor for it public
And as Ben said, follow standard java coding conventions to make it easier for others to understand your code.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: use of bean in jsp
It's not a secret anymore!