Here's an example from a .jsp file:
<%@ page import = "some.package.name.VpnHostsBean" %>

<jsp:useBean id="vpnHosts"
        class="some.package.name.VpnHostsBean" scope="session" />


<HTML>
<HEAD>
...
<TABLE BORDER=0 bgcolor="#336699" CELLPADDING=5 CELLSPACING=2 WIDTH=100%>

<% for (int i = 0; i < vpnHosts.getNumHosts(); i++ ) { %>
        <tr><td bgcolor='#6699CC' width=150 align=right><font face='arial,
san-serif' color='#FFFFFF'>
        <%= vpnxHosts.getName(i) %>
        </font></td>
   <td bgcolor='#DDDDDD' width=350 align=left><font face='arial, san-serif'
color='#000000'>
        <%= vpnHosts.getAddress(i)  %>
   </font></td></tr>
<% } %>

</TABLE>
...

Here's part of the associated bean:
package some.package.name;

import java.util.*;
import java.io.*;


public class VpnHostsBean extends java.lang.Object implements Runnable
{
...
        protected int numHosts = 0;
        public int getNumHosts()        {
                numHosts = addresses.size();
                return numHosts;
        }

        protected Vector names = new Vector();
        public String getName(int i)    {
                return (String)names.elementAt(i);
        }
        protected void setName(int i, String value) {
                if (i >= names.size())
                        names.setSize(i + 1);
                names.setElementAt(value, i);
        }

        protected Vector addresses = new Vector();
        public String getAddress(int i) {
                return (String)addresses.elementAt(i);
        }
        protected void setAddress(int i, String value) {
                if (i >= addresses.size())
                        addresses.setSize(i + 1);
                addresses.setElementAt(value, i);
        }
...
}

Hope that helps,

Larry


-----Original Message-----
From: Joel Reymont [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 13, 1999 11:23 AM
To: [EMAIL PROTECTED]
Subject: Indexed properties / iterating through arrays


Hi!

The JSP 1.0 spec mentions those in exactly two places.
What are indexed properties and how can I work with them?

Alternatively, what's the best way to return an array
from a getProperty() method into the JSP page and interate
through it?

        Thanks, Joel

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to