Thursday, November 18, 2004 06:42 PM
Java Bean reduces coding effort:
session.setAttribute & session.getAttribute stores & retrieves attributes in session. True. Would you prefer calling them for 10 times if 10 items to be stored in session? Or would you prefer bundling up those 10 related items in one bean & just call session.setAtt../getAtt.. for once for that bean?
Java Bean is re-usable component:
For example, you want to process an array of application forms filled up by college students. Each application form contains student personal detail & subjects to chose. You might prefer creating 3 beans called StudentBean & SubjectBean. Third bean is ApplicationBean that has 2 above beans as attributes. Thus data population, processing etc... becomes manageable.
Java Bean keeps data intact:
Easy to pass as parameters to next method.
Java Bean keeps data well-structured:
Which you might find convinient while mapping with XML, Data objects, DB tables etc...
Java Beans helps in maintenance:
In future your JSP screen changes a little bit. Let's say, few attributes added. You know that your Java Bean for that screen will also have respective addition. Easy to maintain.
Java Beans are serializable:
Java Beans gave birth to EJB:
Java Beans are evolved as re-usable components that are coarse grained & used in enterprise applications which are now known as Enterprise Java Beans.