Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the advantage of using useBean - Actions tag  RSS feed

 
Anand Loganathan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the advantage of using <useBean> action Tag in JSP file.
instead of using <useBean> , I can declare instance of an bean like
bean b=new bean().please someone clarify me .
 
ib idris
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The advantage is it better readable for someon who doesn't know Java. Also as it is XML compliant you can use it and do XSLT transformations with it.
http://galileo.spaceports.com/~ibidris/
 
Tim Perkuhn
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you use <jsp:useBean> you declare a id for the bean. With this id you have a reference that can be used in Expressions.
Example:

Also you can declare a scope for the bean, that makes it possible e.g. to store the bean in the session and use it later on.
The jsp:useBean action will first take a look if the bean is allready instanciated and use the existing object or if no instance is present create a new one.
Usage of jsp:setProperty and jsp:getProperty to access the bean get- and set-methods.
If the type names from the bean and the HTML <input .../> element are equal, passing the data with jsp:setProperty goes in one line.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!