<!--File jsp008.jsp Copyright R.G.Baldwin 2000 Rev 02/25/00 Illustrates jsp:useBean Illustrates calling getter and setter methods as well as calling an ordinary exposed method of the bean named exposedMethod(). This file must be stored in the following directory: jswdk-1.0.1\webpages Access http://localhost:8080/jsp008.jsp to run this JSP file in the Sun jswdk-1.0.1 reference implementation of jsp. Requires a bean file named jspBeanTest001.class to be stored in the following directory: jswdk-1.0.1\ examples\Web-inf\jsp\beans\BaldwinBeans The bean must have setter and getter methods for a property named size, and must have an ordinary exposed method named exposedMethod(). --> <html> <body> <P>Example jsp008.jsp<BR><BR> <P> Create or locate an instance of the<BR> bean named:<BR><BR> BaldwinBeans.jspBeanTest001. <jsp:useBean id="theBean" scope="page" class="BaldwinBeans.jspBeanTest001" /> <P>Display default size property of the <BR> bean using the getter mehod.<BR><BR> <%= theBean.getSize() %> <P>Set the size property of the bean to<BR> Large using the setter method.<BR><BR> <% theBean.setSize("Large"); %> <P>Get and display the size property<BR> again using the getter method.<BR><BR> <%= theBean.getSize() %> <P>Invoke an exposed method on the bean. <BR><BR> <%= theBean.exposedMethod() %> <P>Have a good day. </body> </html> Figure 2 |