|
Guidelines, Patterns, and code for end-to-end Java applications.Questions and Answers - Client Tier
1. How should my applets talk to my enterprise beans ? We recommend making services from EJB technology-based components ("enterprise bean services") available to applets through a web-tier servlet. The servlet acts as a facade that unifies the applet's access to back-end data, and isolates the applet code from changes in the enterprise bean classes. It's especially useful for
the servlet to serve XML to the applet, if the applet has need of data
that is structured. If you choose to serve XML, be sure that your
applet uses a small-footprint XML parsing mechanism, such as a
lightweight SAX implementation.
Placing a servlet between the applet and the enterprise beans
the applet uses is good since:
2. Can enterprise bean data be imported directly into a StarOfficeTM spreadsheet? StarOfficeTM spreadsheets cannot directly communicate with enterprise beans, but a servlet or page created with JavaServer PagesTM technology (JSP page) in the web tier can access services in the EJB tier and present the results as XML, which the StarOffice spreadsheet can then import. It's best that communication between J2EE technology-enabled servers and spreadsheets be loosely-coupled. While many spreadsheets incorporate full-fledged application development languages which could, in theory, access enterprise beans directly, such a solution would probably be complicated and brittle. XML makes it easy to present EJB services on the web to non-J2EE clients. Both StarOffice and Excel provide an easy way to transport data over HTTP, and XML manipulation facilities are available from within both applications. When interacting with XML-aware, non-J2EE technology-enabled clients, we recommend using a servlet to expose selected enterprise bean services as XML data sources, and using the client's HTTP transport and XML processing facilities. The Java Pet Store sample application provides an example of this technique. All pending orders in the Java Pet Store are available in XML format from the web page estore/pendingorders.jsp.
This page produces an XML description of the current pending orders.
StarOffice accesses the abovementioned web page, receives the data in
XML format, and displays the data in the spreadsheet. See the
document docs/starofficeDemo.html in the Java Pet Store
install directory for a description of how to access the Java Pet
Store from StarOffice.
This technique is not limited to spreadsheets. Any client capable of
making HTTP requests and using the XML returned from the servlet can
access the Java Pet Store in this way. In fact, this is an identical
solution to the one described in the discussion on
applets and enterprise beans above, except that a spreadsheet is
accessing the XML data source, instead of an applet doing so.
3. Is there a way to import data from EJBs directly into an Excel spreadsheet? Excel can access the Java Pet Store just as can StarOffice. See the document docs/excelDemo.html in the Java Pet Store
install directory for a description of how to access the Java Pet
Store from Excel.
| |||||||||
|
| ||||||||||||