-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Benin,
On 1/25/13 6:56 PM, Benin Technologies wrote:
> I'm new to Tomcat/JSP
>
> I have a JSP page that instantiates a bean, then it access the
> bean through a scriptlet, it works fine. But when I replace the
> scriptlet by a <jsp:getProperty.. tag, it doesn't work
>
> Take my code below : <%= employee.getFirstName() %> IS WORKING, it
> displays the employee's firstname <jsp:getProperty name="employee"
> property="firstName" /> IS NOT WORKING, displays nothing
>
> any idea why ?
>
>
>
> <jsp:useBean id="employee" class="org.company.beans.EmployeeBean"
> scope="request" /> <html><body> <% Vector<EmployeeBean> v
> =(Vector<EmployeeBean>)request.getAttribute("list"); Iterator i =
> v.iterator(); int j = 0; while (i.hasNext()) { employee =
> (EmployeeBean)i.next(); %>
>
> <%= employee.getFirstName() %>
> WORKS <jsp:getProperty name="employee" property="firstName" />
> DOESN'T WORK !! WHY ?
>
> <% } %> </body></html>
Is that the full JSP? It looks like you may have your bean "employee"
in the request scope, and you haven't set a first name. Your loop may
use a page-scoped bean (or really not a scoped bean at all -- you
appear to be simply using inline scriptlets).
Try using <c:foreach> instead of writing a scriptlet for your loop.
What version of Tomcat are you using?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEAREIAAYFAlEGkuQACgkQ9CaO5/Lv0PBQ/ACgj6GheM51mjoYSx8rrcqVfiD4
kwsAn14hemCRA9Dr4nGkvI9VxFaB0EmU
=gFh0
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]