Chapter 7 Developing Applications with PowerJ and EAServer
There are many ways to put together a Web application. A key element in a Web application is an application server for building dynamic Web content from database data. In EAServer, PowerDynamo performs this function.
You create PowerDynamo templates in which you specify tags or scripts that execute a database query and format the retrieved data as an HTML page. This processing is done on the server, and the resulting page is sent back to the Web browser client.
PowerDynamo works with other EAServer tools. You can use Java applets and servlets in your PowerDynamo Web application. You can use PowerJ or PowerSite to develop and debug scripts in PowerDynamo templates.
The network architecture might look like this:
You can use either PowerSite or Sybase Central as the interface for your PowerDynamo development.
Basic HTML forms The simplest PowerDynamo application does not involve Java. The HTML page has an HTML form that collects query criteria from the user. The browser sends the query criteria to a PowerDynamo template to retrieve dynamic content. No validation occurs in the browser. PowerDynamo processes the query and returns an HTML page with the requested data.
JavaScript processing for forms You can validate data collected in a form with JavaScript. The scripts in the HTML page implement the business rules needed for validating the data.
Applet for form validation Instead of an HTML form, the Web page includes an applet in which the user enters information. The applet validates the input and uses it to build a URL that is sent to PowerDynamo to retrieve dynamic content. By encapsulating the processing in an applet, you may be able to reuse it in other pages.
Accessing Java classes A PowerDynamo script can access Java classes stored in the PowerDynamo Web site or in the file system. To access a Java class from DynaScript, call the java.CreateObject method.
The following general procedure gives you an idea of how to develop a PowerDynamo Web application that involves Java. The application uses an applet to validate user input and PowerDynamo to retrieve and display data.
<!--SQL SELECT ...
WHERE ( salesorder.order_date BETWEEN '$startdate '
AND '$enddate ' )
-->
<TABLE BORDER>
<TR><TH>First name</TH>
<TH>Last name</TH>
<TH>Number of orders</TH></TR><!--formatting--><TR><TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
http://www.myhost.com/.../ObtainOrders.stm?
startdate=1999-1-10&enddate=1999-3-11
After a user has entered dates in the applet and clicked to show results, the applet instructs the browser to request the template URL. The PowerDynamo-enabled Web server forwards the request to PowerDynamo. PowerDynamo queries the database and formats the results in an HTML table. The Web server sends the resulting page to the user's browser.
This scenario is described in detail in PowerJ Getting Started.
Copyright © 2000 Sybase, Inc. All rights reserved. |