File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Differnce between Use bean and java instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Differnce between Use bean and java instance" Watch "Differnce between Use bean and java instance" New topic
Author

Differnce between Use bean and java instance

chinnu chinnu
Greenhorn

Joined: May 18, 2005
Posts: 4
difference between <jsp:usebean/> and creation of java class instance in jsp?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Usebean instanciates classes for you.

It takes care of
  • Looking to see if the bean already exists in the specified scope.
  • Instanciating it if it doesn't find it.
  • Binding it to the specified scope.
  • Creating a variable for you to use to refer to the bean.
  • Optionally setting properties only when instanciating if you add setProperty tags to the useBean tag's body.


  • Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
    chinnu chinnu
    Greenhorn

    Joined: May 18, 2005
    Posts: 4
    what i mean that ..between usebean and Instance of java class which one is preferable and why?
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    If you're interested in writing code without scriptlets in it, useBean is the way to go. Even if you're not, it's still a convenient way to do all the things mentioned above with a single tag.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Differnce between Use bean and java instance