tailieunhanh - Java Server Pages: A Code-Intensive Premium Reference- P4

Java Server Pages: A Code-Intensive Premium Reference- P4:Before you begin reading Pure JSP Java Server Pages, you might want to take a look at its basic structure. This should help you outline your reading plan if you choose not to read the text from cover to cover. This introduction gives you an overview of what each chapter covers. | new FileInputStream Read the stored object and downcast it back to a SimpleJavaBean value SimpleJavaBean catch lOException ioe catch ClassNotFoundException cnfe return value public void testBean Create the Bean SimpleJavaBean simpleBean new SimpleJavaBean Use accessor to set property simple property value Serialize the Bean to a Persistent Store storeBean simpleBean Get the Bean from the Persistent Store SimpleJavaBean newBean getBean The newBean s simpleProperty public static void main String args SimpleJavaBeanTester simpleJavaBeanTester new SimpleJavaBeanTester - 31 - try Press enter to continue. catch lOException ioe If you build and run this application the output will look similar to the following The newBean s simpleProperty simple property value Press enter to continue. Adding JavaBeans to JavaServer Pages Now that we understand what JavaBeans are and how they are commonly used let s take a look at embedding them into JavaServer Pages. In the following sections we are going to look at the standard actions used to reference JavaBeans and an example that uses these actions. JavaBean Standard Actions There are three standard actions defined to help integrate JavaBeans into JSPs jsp useBean jsp setProperty and jsp getProperty . jsp useBean The first standard action is jsp useBean . It associates an instance of a JavaBean defined with a given scope and id via a newly declared scripting variable of the same id. The jsp useBean action is very flexible. Its exact semantics depend on the values of the given attributes. The basic action tries to find an existing object using the same id and scope. If it does not find an existing instance it will attempt to create the object. It is also possible to .

TỪ KHÓA LIÊN QUAN