	private void outputTableHeader(ArrayList props, JspWriter out)
		throws IOException
	{
		out.println("<tr>");
		
		// emit property names as table headers
		ArrayList propNames = getPropertyNames(props);
		Iterator iter = propNames.iterator();
		while (iter.hasNext())
		{
			out.println("<th>");
			out.println(iter.next());
			out.println("</th>");
		}
		
		// output close tag for table-heading row
		out.println("</tr>");		
	}
	
	private void outputPropertyRows(ArrayList props, JspWriter out)
		throws IOException
	{
		// display a table row for each object
		// in the collection, with a cell for 
		// each property
		Iterator iter = dataSource.iterator();
		while (iter.hasNext())
		{
			// output a row for each object
			out.println("<tr>");
				
			Object o = iter.next();
				
			Iterator propsIter = props.iterator();
			while (propsIter.hasNext())
			{
				try
				{
					// output a cell for each property
					out.println("<td>");
						
                    // call the "getter" method via reflection
					Method m = (Method)propsIter.next();
					Object ret = m.invoke(o, null);					
					out.println(ret);
				} 
				catch (Exception e)
				{
					out.println(e.getMessage());
				}

				// close the cell
				out.println("</td>");
			}
								
			// close the row
			out.println("</tr>");			
		}		
	}
	
	private ArrayList populatePropertyList()
	{
		ArrayList props = new ArrayList();
		Iterator iter = dataSource.iterator();
		
		// retrieve first object from collection
		// and examine it via reflection
		Object o = iter.next();
		if (o != null)
		{
			// retrieve method list
			Class c = o.getClass();
			Method[] methods = c.getDeclaredMethods();

			// for each method whose name begins with "get",
			// add the Method object to the collection
			for(int i=0; i<methods.length; i++)
			{
				String methodName = methods[i].getName();
				if (methodName.startsWith("get"))
					props.add(methods[i]);
			}
		}
		
		// sort the collection alphabetically by method name
		class NameComparator implements Comparator
		{
			public int compare(Object arg0, Object arg1)
			{
				Method m1 = (Method)arg0;
				Method m2 = (Method)arg1;
				return m1.getName().compareTo(m2.getName());
			}			
		}
		
		Collections.sort(props, new NameComparator());
		
		return props;
	}

	private ArrayList getPropertyNames(ArrayList props)
	{
		// allocate a collection to hold property name Strings
		ArrayList names = new ArrayList(props.size());
		                            		
		Iterator propsIter = props.iterator();
		
		while (propsIter.hasNext())
		{			
			// retrieve a Method object from collection
			Method m = (Method)propsIter.next();	
			
			// strip "get" from getXXXX() 
			// and add property name to collection
			names.add(m.getName().substring(3)); 
		}
						
		return names;
	}

