Friday, December 21st, 2007
EJB & JSP: Java On The Edge, Unlimited Edition by Lou Marco ISBN: 0764548026 Your Guide to Cutting-Edge J2EE Programming Techniques. Chapter 6: JSP and JavaBeans You may recall from Chapter 3 that an essential advantage of using JSP over competing technologies is that JSP enables you to separate the business logic from the appearance of your Web pages. You can separate business logic from presentation by using J2SE and J2EE APIs to code your business logic in Java components and by using static and dynamically generated HTML to code your presentation. Java components called JavaBeans are particularly important to the JSP author. This chapter shows you how to use JavaBeans in your JavaServer Pages, starting with an overview of JavaBeans, including how to access data within JavaBeans in your JSP pages. Several examples of accessing JSP pages and changing data within JavaBeans are shown. At the end of this chapter, you can be ready to use JavaBeans in your JSP pages. A JavaBeans Primer JavaBeans is a topic worthy of entire tomes, but you do not need to be a JavaBeans expert to use them in your JSP pages. The purpose of this section is to cover enough about JavaBeans to show you how to integrate JavaBeans with your JSP pages. JavaBeans Defined Simply defined, JavaBeans are a standard for writing Java software components. As mentioned in Chapter 1, an important virtue of using software components is the ability to plug in components as needed. To accomplish the all- important separation of logic from presentation, it s necessary to discuss how to plug JavaBean components into JSP pages because JavaBeans encapsulate the business logic. Note Do not confuse JavaBeans with Enterprise JavaBeans. Enterprise JavaBeans are JavaBeans with special characteristics that allow them to work with EJB containers. Enterprise JavaBeans are the focus of the second half of this book. Feel free to read ahead in Chapter 11 for a more complete explanation of Enterprise JavaBeans. Note Sun provides the Bean Development Kit, or BDK, for Java developers interested in creating JavaBeans. You can download a copy at http://java.sun.com/products/javabeans/software/bdk_download.html. The JavaBean specifies a component architecture for Java classes where a JavaBean is a public class that (minimally) has an empty constructor, no public instance variables, and get/set methods for accessing persistent data stored within the bean. In other words, a JavaBean is an object with a well-defined interface. Good Java programmers already code Java classes with hidden instance variables encapsulated with accessor methods. You are halfway there to coding JavaBeans for use in your JSP pages!
You need web hosting, easy to use web template and great support. What else could I ask for?All of our reseller accounts include free web hosting templates just check web hosting templates for more information.