Difference Between java bean   And POJO

Hi,
What is the difference between the POJO the plain old javaobject and java bean ,
in my sense what is the basic difference between POJO and the object of a java bean class
Thanks
Arun

http://en.wikipedia.org/wiki/POJO
http://java.sun.com/products/javabeans/

Similar Messages

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • Is there any difference between java Beans and general class library?

    Hello,
    I know a Java Bean is just a java object. But also a general class instance is also a java object. So can you tell me difference between a java bean and a general class instance? Or are the two just the same?
    I assume a certain class is ("abc.class")
    Second question is is it correct that we must only use the tag <jsp:useBean id="obj" class="abc.class" scope="page" /> when we are writng jsp program which engage in using a class?Any other way to use a class( create object)? such as use the java keyword "new" inside jsp program?
    JohnWen604
    19-July-2005

    a bean is a Java class, but a Java class does not have to be a bean. In other words a bean in a specific Java class and has rules that have to be followed before you have a bean--like a no argument constructor. There are many other features of beans that you may implement if you so choose, but read over the bean tutorial and you'll see, there is a lot to a bean that is just not there for many of the Java classes.
    Second question: I'll defer to someone else, I do way to little JSP's to be able to say "must only[\b]".

  • The differents between Java Beans and Enterprise Java Beans

    Please help me!
    What is the differents between JavaBeans and Enterprise Java Beans (EJB) ?
    Thank's for your answer

    Enterprise Java Beans are special type of java beans.
    EJBs invented to be used via remote VMs or remote computer
    systems.They must be deployed on server to become accesible for remote
    clients.

  • What is the difference between Java Beans and EJBs ?

    Hi,
    Can someone tell me that ? Kind of confused... Thanks !
    Philip

    Hmm, I'm gonna have a go at this - hopefully someone will build on it with more differences or requirements:
    A Java Bean is merely a Java class written to conform to some simply rules for construction and method naming eg:
    public class MyBean
      private String myField;
      public MyBean()
      public void setMyField(String myField)
        this.myField = myField;
      public String getMyField()
        return myField;
    }Applications can use Java Beans without having to know about the class in advance - a typical situation might be their use in visual GUI editors where the properties of the bean can be exposed and manipulated by the editor through examination of the method names or an accompanying descriptor.
    An Enterprise Java Bean doesn't have all that much in common with a Java Bean. An EJB is a small set of classes meeting a single (usually) business requirement written to conform to the EJB specification. This enables them to be used by J2EE Application servers to perform enterprise business functions (data storage, manipulation, business logic etc.). The whole idea is that by writing to the specification the server can automatically provide support for transaction management, concurrent access, scaleability, etc that a mission-critical system might require without the programmer having to understand the workings of the application server.
    Essentially an EJB can either
    1) maintain the permanent state of a business object (eg, hold the data for a single product in a catalogue)
    2) perform a small set of business operations (eg, place an order for a customer)
    3) act in response to messages passed around the system (eg, send a mail to the user when the items have been shipped)
    I would have a look at the following two pages to get a better overview:
    http://java.sun.com/products/javabeans/
    http://java.sun.com/products/ejb/
    Hope this helps.

  • Difference between Java class and JavaBean?

    What is the difference between a Java class and a JavaBean?
    A class has variables which hold state.
    A class has methods which can do things (like change state).
    And if I understand a JavaBean it is rather like a BIG class...
    i.e.
    A JavaBean has variables which hold state.
    A JavaBean has methods which can do things (like change state).
    So, what's the difference between the two?
    And in case it helps...What is the crossover point between the two? Is there a minimalist type JavaBean which is the same as a class? What is the difference between Java beans and Enterprise Java Beans?
    Thanks.

    Introspection, as I understand it is a bunch of
    methods which allows me to ask what a class can do
    etc. right? So, if I implement a bunch of
    introspection methods for my class then my class
    becomes a JavaBean?Introspection allows a builder tool to discover a Bean's properties, methods, and events, either by:
    Following design patterns when naming Bean features which the Introspector class examines for these design patterns to discover Bean features.
    By explicitly providing the information with a related Bean Information class (which implements the BeanInfo interface).
    I understand now they are completely different.
    Thanks. Very clear.
    I do not understand how they are completely different.
    In fact I don't have a clue what the differences are
    other than to quote what you have written. In your
    own words, what is the difference? This is the "New
    to Java Technology" forum ;-) and I'm new to these
    things.In that case ejbs are way too advanced for you, so don't worry about it.

  • What is difference between Managed Bean and Backing Bean?

    What is difference between Managed Bean and Backing Bean? Please guide me how to create them and when to use them?
    Please post sample for both beans.

    Hi,
    managed beans and backing beans are quite the same in that the Java object is managed by the JavaServer Faces framework. Manage in this respect means instantiation. The difference is that backing beans contain component "binding" references, which managed beans usually don't. Do backing beans are page specific versions of managed beans.
    Managed beans are configured either in the faces-config.xml file, or using ADF Faces and ADFc, in the adfc-config.xml file
    Frank
    Edited by: Frank Nimphius on Jan 31, 2011 8:49 AM

  • Whats is difference between Java JRE  and  Java SDK

    Hi,
    what is the difference between Java JRE and Java SDK...
    i think both of them have the same set of files to be installed...
    I am not able to understand where they differ

    The JRE (Java runtime Environment) contains just the stuff necessary to run Java and the SDK (System Development Kit) contains the extra stuff necessary (and also helpful) to develop in Java.

  • What's the difference between Java SDK and the Enterprise Edition?

    What's the difference between Java SDK and the Enterprise Edition? Are they both free?

    both r free but they are used in diffrent applications. sdk are used for simple apps that run on your computer while j2e (enterprise edition) are ment for large distributed computer systems that include servers and such. if you don't know the diffrence you probably wont need the the j2e, only the sdk.

  • Difference between Java applet and JavaFX

    Hello, all!
    I am studying javaFX in general. As far as I understand there is no main difference between java applet and javafx, except javafx has different syntax and library simple to use. Is it right?

    Basically, yes. But as you point out, it is supposed to be faster to develop in JavaFX...
    For example, Processing allows to export to applet, and is strong on doing graphics, but to see if user has clicked on a circle, you have to check the mouse coordinates against the circle coordinates, or create your own Circle class: it is at a much lower level.
    Likewise, you can use gaming frameworks like Slick2D or PulpCore, but they might be lacking on GUI (but perhaps faster). Or use Apache's Pivot, strong on GUI, but perhaps lacking a bit on graphics and animation.
    It depends on your needs, if you prefer to stick to Java, etc.

  • [svn] 4112: Further work for FXG to SWF transcoding - checking in some work resulting from collaborating with Kaushal to correct FXG transforms and gradient transforms as well as cater for differences between Java AffineTransform and the SWF Matrix type .

    Revision: 4112
    Author: [email protected]
    Date: 2008-11-14 10:05:42 -0800 (Fri, 14 Nov 2008)
    Log Message:
    Further work for FXG to SWF transcoding - checking in some work resulting from collaborating with Kaushal to correct FXG transforms and gradient transforms as well as cater for differences between Java AffineTransform and the SWF Matrix type.
    QE: Not yet.
    Doc: No
    Checkintests: Pass
    Reviewer: Kaushal
    Modified Paths:
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/GraphicContentNode.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/fills/LinearGradientFillNode.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/fills/RadialGradientFillNode.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/strokes/LinearGradientStrokeNode.j ava
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/strokes/RadialGradientStrokeNode.j ava
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/swf/AbstractFXGGraphics.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/swf/TypeHelper.java
    Added Paths:
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/ScalableGradientNode.java

  • Difference between java.exe and java.dll

    can some one tell me the difference between java.exe under bin directory of jdk and java.dll under bin directory of jre under jdk. and how to determine jre the application is using.How to locate istalled jres in windows registry

    can some one tell me the difference between
    java.exe under bin directory of jdk and
    java.dll under bin directory of jre under jdk.java.dll is the library containing the Java Virtual Machine. java.exe is the
    program you execute to run Java. It uses java.dll. The java.dll can also be used
    to invoke Java classes from other languages using the Java Native Interface (JNI), see
    http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html for more information.
    Steve Dever

  • Differences between Java Servlet and Portlets

    Hello,
    May anyone let me know the differences between Java Servlet, JavaBeans and Portlets? It seems quite similar to each other... By the way, what are differences between a servlet container and portlet container? Thank you.
    Charoite

    JavaBeans are totally different from servlets or portlets. JavaBeans can be used in just about any environment. A JavaBean is basically a java class with a no-arg constructor which follows certain naming conventions for its get and set methods.
    Servlets can only function in an "web containers" which are provided by application servers which support servlets. The main function of servlets is to process requests (usually http requests) and generate output (usually web pages). They usually perform validation and other processing and then delegate the web page generation to a jsp.
    Portlets are similar to servlets but rather than generating an entire web page, their output is relegated to a portion of a page. A single web page may contain the output of several portlets. These portlets can communicate with each other. The portlet container provides the functionality to merge the output of the various portlets and the infastructure required to support the portlets.

  • Performance difference between java.beans.Expression and Java Reflection

    What is the Performance difference between using java.beans.Expression class and Java Reflection classes like Class,Method ??

    negligible

  • Difference between BI Beans and olap api

    HI
    is there anyone can tell me the difference between
    BI and olap api ,
    is BI a language or components ,why
    when i build crosstab with BI beans it uses classes
    different from olap pi classes (oracle.dss.*)
    and olap api (oracle.express.*)
    so BI is another language independent of olap api
    or it uses olap api to connect to OLAP
    BI works , OLAP api doesn't work
    thanks

    Hi,
    This is a great question. The OLAP API is an Oracle published Java API for access to Oracle OLAP. This exposes the OLAP cube/dimension model via Java. The OLAP API documentation can be found on the OLAP secion of OTN, see the link on the BI Beans section of OTN. Within the documention section there is a link to the acle9i OLAP Release 2 - Developer's Guide to the OLAP API:
    http://otn.oracle.com/products/bi/pdf/OLAPIguide.pdf
    Customers can write their own Java code directly against this public API to display and manage OLAP objects. The OLAP API documentation explains how to do this.
    As users typically will want to present OLAP data in either a crosstab and/or graph Oracle created a pre-packaged set of components to help customers to quickly and easily create powerful OLAP applications. BI Beans are a set of fully J2EE compliant java beans that provide major components such as:
    - presentation beans (graph/crosstab/table)
    - OLAP beans
    - catalog services beans
    These components have extensive APIs to allow developers to comprehensively customize an application, both Java client and thin client (HTML/JSP and UIX).
    By default BI Beans connect to an Oracle database using the OLAP API as a primary data source (although users can create their own non-OLAP data sources). This allows developers and end-users to directly access dimensions and measures created to the OLAP specification.
    This is explained in more detail in the Oracle BI Beans Technical Whitepaper:
    http://otn.oracle.com/products/bib/htdocs/collateral/bi_beans_white_paper.pdf
    Hope this helps
    Business Intelligence Beans Product Management Team
    Oracle Corporation

Maybe you are looking for

  • COnnecting 4th Generation Ipod to Alpine...

    My U2 edition works on firewire not USB and won't work with my new stereo... is there a firmware update or something to make it work with USB? thanks.... John

  • Very basic question Oracle spatial query

    Hi All, Iam a newbie to oracle spatial. How can i verify that oracle spatial is installed in my database. My database is version is 10.2.0.2.0 Is there any special query i can execute to test oracle spatial is working properly / installed properly. A

  • Ipod completely dead?

    my ipod wont do anything at all. i've read through some posts in this forum. and they at least get some sort of symbol. whether it be a sad face or a charging icon. my ipod doesnt do anything. i've tried the 3 R's or whatever in the trouble shooting

  • Mozilla Firefox is crashing non-stop, no matter what.

    The Mozilla Crash Report appeared on my computer screen recently so I went about trying to figure out the problem. I tried to open Firefox again and it wouldn't. I opened in Safe Mode and it worked until I tried to navigate away from the start page.

  • Find a metacharacter column in InDesign

    Hello! I will be grateful if someone can help me. How can I search the metacharacter column in InDesign. I want to insert a tab character before the metacharacter with find/change (text or grep) Thank you in advance.