Using JavaBeans Components in JSP Documents
Contents 1. Why using beans? 2. What are beans? 3. Using Beans: Basic Tasks 4. Sharing Beans 5. Practice exercise
1. Why Use Beans? - Separate class are easier to write, compile, test, debug and reuse. - No Java syntax - Simpler object sharing - Convenient correspondence between request parameters and object properties. - (Part II, chapter 14)
2. What Are Beans? A bean class must have a zero- argument (default) constructor A bean class should have no public instance variables (fields) Persistent values should be accessed through methods calledget Xxx and setXxx
3. Using Beans: Basic Tasks jsp:useBean jsp:getProperty jsp:setProperty
Accessing Bean Properties: jsp:getProperty
4. Sharing Beans
5. Practice Exercise Develop a WebApp to manage product information. The WebApp allow use add and update a product. Each product has name, description, price, producer name.
Create JSP to add new Product using Product bean productType.insert(conn)