<jsp:useBean id="myBookBean" class="com.java2s.Book"
scope="session">
<%-- The setProperty tag is only executed when a JavaBean is created --%>
<jsp:setProperty name="myBookBean" property="author" value="Joe" />
</jsp:useBean>
<html>
<head>
<title>When a JavaBean already exists...</title>
</head>
<body>
The author of your book is <jsp:getProperty name="myBookBean"
property="author" /><P>
Click <a href="beanAlreadyExists2.jsp">here</a> to see another page that
declares a JavaBean that uses the same name and scope.
</body>
</html>
//beanAlreadyExists2.jsp
<jsp:useBean id="myBookBean" class="com.java2s.Book"
scope="session" />
<html>
<head>
<title>When a JavaBean already exists...</title>
</head>
<body>
This page redeclares the JavaBean, but does not set any of its properties.
The same name and scope were used for the JavaBean, so the original bean
is used.
<P>
The author of your book is <jsp:getProperty name="myBookBean"
property="author" /><P>
</body>
</html>
|