JSP is a java servlet page, basically still a servlet in infrastructure but created in such a way to allow
seperation of the VIEW from the MODEL / CONTROLLER.
A "java bean" is a .jar file (compiled java) that is created from a class with a public constructor and
is usually serializable.
An Enterprise Java Bean is the result of trying to address the MODEL portions of a Java Web Application
(i.e. database persistence) - variations created can be:
Stateful - one client connection/state to this bean (i.e. online store shopping cart)
Stateless - non concurrent (thread safe) business object that has no state (i.e. sending a feedback form's contents)
Singleton - global shared state in the JVM (loading a piece of news that many clients will read)
Create a basic greeterbean.java file:
package mypackage;
public class greeterbean
{
public greeterbean() { }
public String greeter( String input )
{
return "Your bean is ready, your message was: " + s ;
}
} //end class
compile a class into a .jar and put it in the webapps/APPNAME/WEB-INF/lib direcotry
javac greeterbean.java
mv greeterbean.class /var/lib/tomcat6/webapps/Greeter/WEB-INF/lib
Create a basic index.jsp file:
<jsp:useBean id="name" class="package.class" />
jsp:useBean a new object is instantiated only if there is no existing one with the same id and scope