Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems


Returning a Java Class from a Method Call or Field Access

A Java object returned from a Java method call or field access in a client script is automatically wrapped in its own Chili!Beans wrapper. For example, the classes Table and Record are defined as:


package Database ;

public class Table {

public Table(String name, in initialSize) {...}; 

public int numRecords() {...}; 

public Record getEmployee(int employeeNumber) 





package Database ;

public class Record {

public Record() {...}; 

public String m_LastName ; 

public String m_FirstName ; 



The following ASP script will print the names of the employees in Table:

set t = Server.CreateObject("Chili.Beans")

t.ClassName = "Database/Table"

t.Construct "Employees", 100

for I = 0 to t.numRecords - 1

set record = t .getEmployee(I) 

Response.Write(record.m_FirstName & " " _ 

& record .m_LastName & "<br>") 


The Java objects returned by the getEmployee calls on the Table object are automatically given Chili!Beans wrappers and their methods and fields are available even though they have not been constructed with the CreateObject method.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.