Sorry about that. I should have included how I declared the bean. The
<jsp:useBean> tag is the 2nd line in the page, right after the
<jsp:Page> tag. The full tag reads:
<jsp:useBean id="emp" class="test.EmployeeBean" />
I've traced through the servlet code and the bean's getters are being
called even in the getProperty cases.
In the generated servlet code the scriptlet's version of getting the
title is:
out.print( emp.getTitle() );
The getProperties version is:
out.print(JspRuntimeLibrary.toString((((test.EmployeeBean)pageContext.fi
ndAttribute("emp")).getTitle())));
- Rich
-----Original Message-----
From: Randy Layman [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 22, 2002 7:59 AM
To: 'Tomcat Users List'
Subject: RE: Strange javabean problem
You are not creating a bean named emp for the jsp:getProperty.
You need to use jsp:useBean first (I believe) or use
<%=emp.getFirstName()%>.
Randy
> -----Original Message-----
> From: Rich Sneiderman [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 22, 2002 11:39 AM
> To: Tomcat Users List
> Subject: RE: Strange javabean problem
>
>
> I can't believe we're the only people who have ever seen this problem.
>
> I'm still having the problem but I got to the same place differently.
>
> I load the data from a data base in a servlet. The servlet reads from
> the database it creates a javabean for each record and adds it to a
> ListArray. I then add the ArrayList to the request object and forward
> on to my JSP. It's this ArrayList that I'm iterating through in my
> JSP when I have the problem.
>
> Again here is my code snippet that fails:
>
> <%
> ArrayList la = (ArrayList) request.getAttribute("list");
> if ( la != null ) {
> Iterator iter = la.iterator();
> while(iter.hasNext()) {
> emp = (EmployeeBean)iter.next();
> %>
> <tr><td><%= emp.getFirstName() %></td>
> <td><%= emp.getLastName() %></td>
> <td><%= emp.getTitle() %></td>
> </tr>
>
> <tr><td><jsp:getProperty name="emp" property="firstName" /></td>
> <td><jsp:getProperty name="emp" property="lastName" /></td>
> <td><jsp:getProperty name="emp" property="title" /></td> </tr> <%
> }
> }
> %>
>
> Could there be something wrong with the way we're defining our
> Javabeans?
>
> Please folks. A little help here.
>
> Thanks in advance.
>
> - Rich
>
> -----Original Message-----
> From: Michael J. McCormac [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 21, 2002 7:45 PM
> To: [EMAIL PROTECTED]
> Cc: Rich Sneiderman
> Subject: RE: Strange javabean problem
>
>
> > Hi Folks,
> >
> > I'm using Tomcat 4.01 with Jbuilder 6. I've got a strange problem.
> > It seems that if I try to dump data from a Java bean using the
> > <jsp:getProperty> tag I don't get the data. However, if I
> reference
> > the value of the bean directly in a scriptlet it works fine.
>
> greetings all,
>
> i am having pretty much the same problem, but the implementation is a
> little bit different. i tried using an rmi process to retrieve the
> bean directly from the JSP like so:
>
> <jsp:useBean id='myBean' class='beans.MyClass' />
> <%
> rmiInt rmiServer = (rmiInt)Naming.lookup( "//server/service" );
> myBean = (MyClass)rmiServer.getBean();
> %>
> <jsp:getProperty name='myBean' property='lastName' /> <-
> doesn't work!
>
> one way i've managed to work around the problem was by creating and
> loading the beans in a servlet first, throwing the beans in the
> session object, then redirecting to the JSP file where i could pull
> them back out of the session like this:
>
> <jsp:useBean id='myBean' class='beans.MyClass' />
> <% session.getAttribute( "mybean" ); %>
> <jsp:getProperty name='myBean' property='lastName' /> <- works ok!!
>
> but i don't like this solution... it's inelegant ;)
>
> thanks,
> mike
>
>
> --
> To unsubscribe: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe: <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>