• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

how to write a bean class?

 
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
 
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 ...
 
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
 
We don't have time to be charming! Quick, read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic