• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to write a bean class?

 
nagalatha mitta
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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 :



Or,



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

Best of luck ...
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your Servlet create the bean and place it into whatever scope you choose with the id you want to use
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic