Arne Vajh?j wrote:
The bean need to be available in one of the scopes.
The only way of doing that in pure JSP is to use the useBean tag.
But you can also make it available from scriptlet Java code or from a
servlet or from some code called by a servlet.
BTW, with EL then I would consider the getProperty tag to be
obsolete.
Well not quite true. If you set the property with something other
than page scope then it apparantly has be with useBean !
(at least with my Tomcat version)
Example:
<%@ page import="test.C" %>
<%
request.setAttribute("v1a", new C("foo"));
session.setAttribute("v2a", new C("foo"));
application.setAttribute("v3a", new C("foo"));
pageContext.setAttribute("v4a", new C("foo"));
%>
<jsp:useBean id="v1b" scope="request" class="test.C"/>
<jsp:setProperty name="v1b" property="s" value="bar"/>
<jsp:useBean id="v2b" scope="session" class="test.C"/>
<jsp:setProperty name="v2b" property="s" value="bar"/>
<jsp:useBean id="v3b" scope="application" class="test.C"/>
<jsp:setProperty name="v3b" property="s" value="bar"/>
<jsp:useBean id="v4b" scope="page" class="test.C"/>
<jsp:setProperty name="v4b" property="s" value="bar"/>
${v1a.s}${v1b.s}<br/>
${v2a.s}${v2b.s}<br/>
${v3a.s}${v3b.s}<br/>
${v4a.s}${v4b.s}<br/>
foo<jsp:getProperty name="v1b" property="s"/><br/>
foo<jsp:getProperty name="v2b" property="s"/><br/>
foo<jsp:getProperty name="v3b" property="s"/><br/>
<jsp:getProperty name="v4a" property="s"/><jsp:getProperty name="v4b"
property="s"/><br/>
Hmm... when I use the <jsp:getProperty>