Java Tutorial/JSP/Get Set Property
Using jsp getProperty to get value from java bean
Jsp code
<HTML>
<HEAD>
<TITLE>Getting a Property Value</TITLE>
</HEAD>
<BODY>
<H1>Getting a Property Value</H1>
<jsp:useBean id="bean1" class="beans.Test4" />
The message is: <jsp:getProperty name="bean1" property="message" />
</body>
</html>
Using setter to change value and read it back by jsp get property
Jsp code
<HTML>
<HEAD>
<TITLE>Using Beans and Session Scope</TITLE>
</HEAD>
<BODY>
<H1>Using Beans and Session Scope</H1>
<jsp:useBean id="bean1" class="beans.Counter" scope="session" />
<%
bean1.setCounter(bean1.getCounter() + 1);
%>
The counter value is: <jsp:getProperty name="bean1" property="counter" />
</BODY>
</HTML>