Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Why bother with Beans in JSP?


Message #1 by <richardbondi@y...> on Wed, 18 Jul 2001 11:02:22 -0400
While the word "scope" applies in both circumstances they have different 
specific meanings.
public
protected
default (package)
private
This bears no relation to scope in JSP, as the operation of scoping rules 
needed in a Bean exist irrespective of the JSP scope employed.
Session scope is probably of most interest. Here you make best use of the 
fascilities offered by the Servlet engine for object storage and sharring 
attached to a particular identifable client.
Nevertheless, if we look at the difference between custom tags and using 
JavaBeans with the <jsp:useBean> tag there is more flexibility.
The tag exstension is itself a JavaBean, but it is not restricted to 
calling other Beans. It can call classes which need not have empty 
constructors. They can be passed values at initialization, rather than 
having to have properties set with jsp:setProperty from the posted client 
form or additional custom scriptlets.
By nesting tag classes it can be possible to maintain a seperation between 
control and presentation using more generic and reusable componants than 
Beans might provide.
BTW, if you use a class you cannot use the jsp:useBean tag and you will 
forfeit several features, for instance the ability of Tomcat to reload 
updated Beans.

  Return to Index