<%
Book myBook = (Book) session.getAttribute("myBookBean");
if ( myBook == null)
{
myBook = new Book();
myBook.setAuthor("Joe");
session.setAttribute("myBookBean", myBook);
} // end of if ()
%>
This page creates a JavaBean if you don't already have one.
Click here to go to a page that retrieves it.
//page2_scriptlet.jsp
<%@ page import="com.java2s.Book" %>
<%
Book myBook = (Book) session.getAttribute("myBookBean");
%>
This page retrieves a JavaBean, and its properties.
| JavaBean property | Value |
|---|---|
| id | <%= myBookBean.getId() %> |
| title | <%= myBookBean.getTitle() %> |
| author | <%= myBookBean.getAuthor() %> |
| price | <%= myBookBean.getPrice() %> |
///JavaBean usage - useBean and setProperty tags
scope="session">
This page creates a JavaBean if you don't already have one.
Click here to go to a page that retrieves it.
//useAndSet2.jsp
This page retrieves a JavaBean, and its properties.
| JavaBean property | Value |
|---|---|
| id | |
| title | |
| author | |
| price |


No comments:
Post a Comment