Introduction to Java Server Pages
 
Calling JavaBeans
 
JSP technology allows separating the development efforts between the HTML code that determines static page presentation, and the Java code that processes business logic and presents dynamic content. It therefore becomes much easier to split maintenance responsibilities between presentation and layout specialists who may be proficient in HTML but not Java, and code specialists who may be proficient in Java but not HTML.In a typical JSP page, most Java code and business logic will not be within snippets embedded in the JSP page--instead, it will be in JavaBeans or Enterprise JavaBeans that are invoked from the JSP page. JSP technology offers the following syntax for defining and creating an instance of a JavaBeans class
<jsp:useBean id="pageBean" class="mybeans.NameBean" scope="page" />
 
This example creates an instance, pageBean, of the mybeans.NameBean class. Later in the page, we can use this bean instance, as in the following example
Hello <%= pageBean.getNewName() %> !
 
 
This prints "Hello Aman !", for example, if the name "Aman" is in the newName attribute of pageBean, which might occur through user input. The separation of business logic from page presentation allows convenient division of responsibilities between the Java expert who is responsible for the business logic and dynamic content (the person who owns and maintains the code for the NameBean class) and the HTML expert who is responsible for the static presentation and layout of the Web page that the application users see (the person who owns and maintains the code in the .jsp file for this JSP page)