Serving Up Java Pages

Mark Buchner

Now is the time to start your e-business solution and raise your Internet profile. Java has all the necessary tools, and it has proven itself as the premier Web development language. In order to implement your Java e-business solution, you'll be required to take advantage of all the Java technologies available.

Some of the business-type processes will require you to implement JavaBeans and Servlets, which can be combined with a new technology, finalized by Sun in May of this year, called Java Server Pages (JSP). You can use JSP to incorporate many of the Java technologies needed to raise your Internet profile, as well as take advantage of the AS/400 and the features it can provide.

JSP is an amalgam of HTML and the Java language, a concept very similar to Microsoft's implementation of Active Server Pages (ASP). ASPs use a Visual Basic-like script instead of Java, which also takes advantage of HTML tags.

These components are combined in a text file with the extension .jsp. When invoked, they're interpreted at run-time by the JVM (Java Virtual Machine) and the results are provided to the browser. Some uses can include presentation of a recently submitted order form processed by a Servlet, or it can use another Java application (such as a JavaBean) to send E-mail.

JSPs are based on the recently finalized Sun JSP 1.0 specification. IBM's implementation on the AS/400 with the IBM HTTP Server is based on the 0.92 specifications.

When the browser requests a page or submits a form, the Web server receives the information and identifies it as a JSP by checking the configuration file. Once it's been identified as a Java process, the Web server passes it to the Servlet Manager, which passes it to the JSP Processor to retrieve the source for the JSP and check to see if it's been executed before. The JSP processor will pass the source code to be compiled. It timestamps the bytecode and saves it on the AS/400 so it can be reused in future requests.

The JSP Processor only compiles the source code if it's been changed, or if it's never before been compiled. After receiving the bytecode, the JSP Processor returns it to the Servlet Manager to be passed to the JVM for execution. Once it has processed the bytecode it returns the results, which contain HTML tags to the Servlet Manager. The Servlet Manager passes the results to the Web Server, which passes it along to the browser. Finally, the browser deciphers the HTML tags and presents it to the user.

JSPs have the ability to include JavaBeans and Enterprise JavaBeans in the source code. JavaBeans can be incorporated to allow for the reuse of Java code in the way of reusable components. Enterprise JavaBeans can also be used to extend transaction-based processing in the form of reusable components. A tool like WebSphere Studio can aid in the development of JavaBeans.

In order to use a JavaBean in a JSP, you must first identify the bean using the tags. Once the bean's properties are set, it's executed by initiating a method. A property, in the example of an e-mail application, could be the e-mail address of the receiving party. A method in this example could be the sending of the e-mail.

With the use of the WebSphere Application Server, you can incorporate your back-end Java Servlets into your JSP. Servlets are a way to write business logic using Java and deploy them via thin clients. WebSphere accesses the AS/400 using connectors that can read the AS/400's databases, legacy application and mail and groupware applications. Similarly, Servlets are identified to JavaBeans using the tag. Once identified, the Servlet can be accessed and executed anywhere throughout the JSP.

Visual Age for Java 2.1 Enterprise Edition allows for interactive debugging of JSPs. During the execution of the JSP, you can view the current line of execution, the Java source that has been dynamically created, as well as the HTML being generated. With this debugging tool, you can insert breakpoints to stop the processing and view the results generated. This tool provides an efficient way to control the output, as well as the end-results generated by the JSP.

There are a few requirements to use JSPs on your AS/400. The IBM HTTP Server must be installed and configured on your AS/400. In order to take advantage of JavaBeans and Servlets, you'll be required to have the WebSphere Application Server installed, as well as the JDK (Java Development Kit) version 1.1.4. These are all available as non-chargeable licensed programs from IBM.

JSP is a quick and efficient method of incorporating Java applications into your e-business solution. With this type of Java implementation, it's possible to take advantage of both the Java language and HTML tags. HTML is a quick and easy way to manipulate text, while Java is an effective method of accessing your AS/400 and other Java processes. Together, they can be used to massage the results into an attractive and powerful Java-based site.