jQuery in Action, 3rd edition
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes how to write a bean class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "how to write a bean class?" Watch "how to write a bean class?" New topic

how to write a bean class?

nagalatha mitta

Joined: Jun 11, 2007
Posts: 26
hi friends
HFSJ book says that if "type" is used without "class" ,the bean must already exist.My doubt is how to write a bean class code,so that bean is already stored as an attribute at the scope and with the "id" we have put in <jsp:useBean> tag.
anybody let me know please

thanks in advance
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585

Write a standard JavaBean, put it in /WEB-INF/classes, and then in your JSP page, when using the <jsp:useBean> tag provide the full path of the class or import it using a page directive.

As an example, if the JavaBean was written in a package named beans, you have to say :


Make sure that your bean must have a public no-arg constructor.

Best of luck ...

Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
In your Servlet create the bean and place it into whatever scope you choose with the id you want to use
I agree. Here's the link: http://aspose.com/file-tools
subject: how to write a bean class?
It's not a secret anymore!