L08-JavaBeans - Session 8 Java Beans Session 8 JavaBeans 1...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Session 8 – Java Beans 9/27/2010 1 © Robert Kelly, 2001-2010 Session 8 JavaBeans 1 Reading Head First –Chapter 3 (MVC) Reference JavaBeans Tutorial- java.sun.com/docs/books/tutorial/javabeans/ © Robert Kelly, 2001-2010 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Session 8 – Java Beans 9/27/2010 2 © Robert Kelly, 2001-2010 Lecture Objectives Understand how the Model/View/Controller design pattern applies to Web applications Understand how a Java Bean is used to store data in a Web application Know the features a Java class must possess to be considered a Java Bean © Robert Kelly, 2001-2010 3 Know how to use a servlet to move form data into a Java Bean Web Architecture Web layer Clients JSP Page Bean servlet Bean Session Other shared objects © Robert Kelly, 2001-2010 4 JSP Page Web applications are usually constructed with the Model, View, Controller pattern
Background image of page 2
Session 8 – Java Beans 9/27/2010 3 © Robert Kelly, 2001-2010 Model / View / Controller Pattern Web systems are usually decomposed into MVC components For now, just think of a JSP as an easy way JSPs – view Servlets – controller Java Beans (and custom tags) - model Data and business logic for a Web application are usually stored in objects that are visible to servlets to write a servlet that generates HTML © Robert Kelly, 2001-2010 5 and JSPs The handle to a bean is usually stored in the relevant shared object (e.g., Session and ServletContext) JavaBeans and Web Applications A bean is an object that you can easily use within your JSP or servlet You can create a bean within your JSP or servlet You can share a bean with other JSPs and servlets and thereby share data You can get and set properties in the bean © Robert Kelly, 2001-2010 6 Bean data can be persistent
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
9/27/2010 4 © Robert Kelly, 2001-2010 MVC Web Architecture Controller Model JSP Page Bean servlet Session Other shared © Robert Kelly, 2001-2010 7 JSP Page Bean objects View What Makes a Bean a Bean? A bean is an instance of a Java class that: Must have a zero argument constructor Should have no public instance variables Should have (properly named) get and set methods for any instance variables that are to be accessed (setter argument type and getter return type must be identical) Must support persistence (the bean is serializabl © Robert Kelly, 2001-2010 8 Must support persistence (the bean is serializable) A bean usually supports events either by firing
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/22/2011 for the course CSE 336 taught by Professor Kelly,r during the Fall '08 term at SUNY Stony Brook.

Page1 / 12

L08-JavaBeans - Session 8 Java Beans Session 8 JavaBeans 1...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online