12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 11 ■ PAGES AND COMPONENTSTable 11-1. JSP Action ElementsActionuseBeansetPropertygetPropertyincludeforwardparampluginparamselementattributebodyDescriptionAssociates an instance of an object <strong>with</strong>in a given scope and available <strong>with</strong> a given ID.Sets the value of a property in a bean.Displays the value of a bean property.Allows the inclusion of static and dynamic resources in the same context as the currentpage.Dispatches the current request to a static resource, a JSP, or a servlet in the same contextas the current page.Is used in the include, forward, and params elements. The included or forwarded pagewill see the original request object <strong>with</strong> the original parameters augmented <strong>with</strong> the newparameters.Enables a JSP to generate HTML that contains the appropriate browser-dependentconstructs (OBJECT or EMBED) that will result in the download of a plugin.Passes parameters. This is part of the plugin action.Dynamically defines the value of the tag of an XML element.Defines an XML attribute. This is part of the element action.Defines the body of an XML element. This is part of the element action.Putting It All TogetherThese elements allow you to invoke <strong>Java</strong> code and any kind of component (EJBs, databases, webservices, etc.). As an example, let’s write some <strong>Java</strong> code. The web page that you want to create has todisplay a list of books stored in an ArrayList. There is no database access, just an ArrayList initialized<strong>with</strong> a fixed number of Book objects through which the JSP iterates and displays the attributes (ISBN, titleof the book, description, and so on). The result should look like Figure 11-5.310

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!