tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Go" <>
Subject <jsp:getProperty> vs. <% out.println(bean.getID()) %>
Date Wed, 26 Jul 2000 16:50:56 GMT

Been trying to figure this out for a week now.  Running Apache/Tomcat on Solaris.
This app is primarily being developed using a servlet serving out JSP pages based on a command
parameter passed into the servlet.  The servlet then creates the bean (or beans) then returns
them to the JSP page.

Ideally, I would like to use <jsp:getProperty id="beanName" property="beanID"> on single
beans OR an array (or vector) of beans that is returned by the servlet using the request.setAttribute
method.  This method works on single beans (meaning if there is only one bean being returned).
 This method (<jsp:getProperty), however, does not work when I try to loop through an array
of beans.  As a temporary workaround, I am using 
<% out.println(beanName.getBeanID()) %>
to achieve the same effect and it works.  In the same loop, I try to use the <jsp:getProperty>
tag but it keeps initiating a "blank" bean.  If I change the <jsp:getProperty> tag to
try to grab a non-existent property, it bombs so I know that it is working properly but it
loads up a "blank" bean (meaning the getBeanID, etc. is blank or whatever is in the constructor).

My code looks like this:
<jsp:useBean id="bug" class="com.msmedia.extranet.BugBean" />

    int count = 0;
    BeanName[] newBeans = (BeanName[])request.getAttribute("list");  
    for (int i = 0; i < newBeans .length; i ++) {
    newBean = newBeans[i];
    <li><jsp:getProperty id="newBean" property="beanID"> | <% out.println(newBean.getBeanID());

The <jsp:getProperty> returns me a zero (0) -> this is what the constructor does
(creates a bean with BeanID = 0) BUT, in the same loop, using the same method within the bean,
the <% out.print %> returns me the proper data I want, which is the beanID.  Again,
the <jsp:getProperty> tag works on single beans on the same application/context/server
but it does not work on arrays or vectors.


Any ideas on why this is happening?


Christopher Go <> 
Vice President, Operations
Mindshare Media Corporation <>
Work: 949.717.6464  |  Mobile:  714.915.3857

View raw message