Forums Register Login

jsp:useBean usage

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
    Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 1033 times.
    Similar Threads
    Trouble with the term "Standard Action"
    Can we have jsp:getProperty without jsp:useBean
    (URGENT) Singletons and JSP pages
    display all items from a list
    <jsp:usebean ... body
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 12:02:48.