• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:useBean usage  RSS feed

 
Marco Yuen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am always confused about the use of <jsp:useBean> to create an object instance and the use of just simply a class in a package provided. Could anyone tell me the main difference? Giving examples and situation on why using <jsp:useBean> would be highly appreciated!
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco
I'm not a jsp or bean expert but if I understand your question correctly you want to know why to use a bean instead of a regular class.
To be a bean a class meets certain specific requirments, such as accessor methods, that may or may not be in another class. Because of this you can use things like this:
That you wouldn't be able to use with a normal class. I'm sure there are other benefits too that I'm not aware of. someone else can probably give you a better explaination.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
useBean
  • Removes some Java code from the JSP. JSPs should, in most cases, ideally have no Java code at all.
  • Retrieves rather than instantiates the bean if it already exists in the specified scope.
  • Binds the bean in the specified scope after instantiation.
  • Makes the bean available to actions such as get/setProperty, and to custom tags.
  • Hope this helps,
    - Peter
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!