• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP and JavaBeans ??  RSS feed

 
Rajesh Venkatesh
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The original JavaBeans specification is based on the java.beans package which is a standard package in the JDK.
But when i use <jsp:usebean> i do not specify
java.beans package ? Is the java bean used
in JSP by <jsp:usebean> similiar to the mentioned
above (java.bean package and which usually
associated with so called BDK)
Thanks & Regards,
Rajesh .V
 
Hartmut Ludwig
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
normally you would write a normal Class providing a parameterless constructor and implementing serializable. This is everything a class needs to be called a JavaBean.
A Bean typically offers public get and set methods (so called accessors) to provide access to the private properties.
The above is valid for Beans following the strict recommendations and requirements of the Spec (e.g. if you want to use them as visual beans in an IDE).
If you wish to use Beans in the JSP context you don't even need to fulfill the mentioned requirements. It is enough if you provide get- and set-methods (which are good coding style anyway) for the properties you wish to access in the JSP.
So you can actually use all classes that provide access to your business logic using getters and setters without any changes as bean within your JSPs. You don't need to fulfill the strict requirements of the JavaBean Specification.
As to the package. If you wish you can implement java.beans (to assist when adding properties).
hope it helps
Hartmut
 
Rajesh Venkatesh
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay got it !!
Thanks Hartmut !
Just a another doubt?
IF used in JSP context then Java Beans
will be Server - side components and if used
in a non-Jsp context is it Client side component??
Please let me know if i am right and if so how ?

[ September 23, 2002: Message edited by: Rajesh .V ]
 
Chris Smith
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beans are beans... it's just a fancy way of saying "class with accessors and mutators that follow certain naming conventions". It's true that beans were first intended for use with client-side GUI designers... but being client-side isn't any part of the definition of the word.
Chris
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!