HTML and Java Developers Unite How to Create a Harmonious Web Site Using HTML, Java Server Pages, and XML

HTML and Java Developers Unite How to Create a Harmonious Web Site Using HTML, Java Server Pages, and XML White Paper December, 1999 Java Server Pa...
Author: Nigel Chandler
0 downloads 2 Views 221KB Size
HTML and Java Developers Unite How to Create a Harmonious Web Site Using HTML, Java Server Pages, and XML

White Paper December, 1999

Java Server Pages – XML – Java – XSL based applications How to create a harmonious Web site with HTML and Java developers

The introduction of Java 2 Enterprise Edition (J2EE) has gained far-reaching vendor and customer support. One of the key sets of features is contained in the Java Server Pages (JSP) technology. While JSP’s have been around for quite some time, Javasoft’s JSP 1.0. and 1.1. standards have greatly solidified the technology for wide spread adoption. What are Java Server Pages? An easy way to think of JSP’s is as HTML with about a dozen added tags. Those additional tags enable the embedding and calling of application logic and other JSP pages – essentially separating the user interface from content generation. This separation allows designers to change the overall page layout without altering the underlying dynamic content. Sun’s Javasoft division has used their community process to arrive at the specification. See the end of this paper for a convenient list of resources on Java Server Pages. JSP’s are actually an extension to Java Servlets. A JSP file gets compiled into a Servlet for runtime execution. A Servlet is an API also specified by Javasoft that extends the functionality of web servers for executing business logic. Servlets were originally conceived to be a Java implementation that improved on the original concepts of a CGI. Servlets run in a servlet engine – typically found as extensions to web servers. Bluestone has implemented a servlet engine in our application server. This gives advantages of scalability, fault tolerance and security since the application logic can be held behind the web server on the inside of a firewall. The following diagram explains the process of starting with a JSP, and executing it as a dynamic page. The steps are: Application Server or Web Server

JSP

Compile

Servlet

Deploy

Servlets

1. Compile the JSP into a Servlet. 2. Deploy the Servlet in a servlet engine – typically a web server or application server such as Bluestone’s Sapphire/UBS, which is the heart of the application infrastructure in Total-eBusiness.

HTML and Java Developers Unite

Page 2 of 6

Note that this process can happen dynamically. The Bluestone Sapphire/UBS has the ability to automatically get new versions of a JSP when a user clicks on that JSP. Then it automatically compiles the new version into a servlet and runs the servlet to display the page. As Javasoft states: “Together, JSP and Servlets provide an attractive alternative to other types of dynamic web scripting/programming that offers platform independence, enhanced performance, separation of logic from display, ease of administration, extensibility into the enterprise and most importantly, ease of use.” JSP’s are also frequently compared to technologies like Microsoft’s Active Server Pages (ASP’s) and Allaire’s Cold Fusion Markup Language. The JSP technology has the added benefit of being integrated tightly into the Java platform. A final note about Java Server Page development. Since the JSP spec is fundamentally a handful of tags added to HTML, almost any HTML tool can be used to develop JSP’s. Bluestone has added the JSP tags to both Dreamweaver and Homesite to serve as examples of this type of integration. Most HTML tools will likely add this functionality soon, which means that HTML developers will not have to leave their favorite tool (or tools) to learn another way of creating dynamic web pages. How to add logic to JSP’s JSP’s were designed to enable a typical HTML developer to use them very quickly, as well as to enable very complex applications to be built. While application logic can be embedded directly in the JSP page (like making specific SQL calls to a database), it is typically recommended to simply “call” the business logic encapsulated in Java Beans of EJB’s. This maintains a very clean separation of content from presentation. It also is a very powerful paradigm to let HTML and Java developers work together. The HTML developer works with the HTML and JSP tags that call the Beans, while the Java developer develops the Beans and database access functionality. How JSP’s interact with Beans and EJB’s JSP developers interact with beans through three primary tags today: Appropriate arguments are passed to “set” and “get” the appropriate properties, such as taking inputs from an HTML form and using them as inputs to a database update statement held within the Bean. Note also that there is no difference from the JSP perspective of calling simple Java Beans or EJB’s. The JSP 1.1 version of the specification introduces the idea of Taglibs. This expands the ability to introduce XML-like tag interfaces to calling Beans. Taglibs will improve the usability of JSP's for HTML developers.

HTML and Java Developers Unite

Page 3 of 6

Leveraging XML While JSP’s can be implemented in a number of ways, Bluestone is suggesting the use of XML as a powerful interface between the JSP and the application logic held in the Java Bean or EJB. The following diagram shows the basic philosophy:

JSP – XML – Beans – XSL Total-e-Business Server

Sapphire/UBS Sapphire/UBS Java JSP Page Sapphire/UBS Beans or XML Web Server



EJB’s

Databases, other data sources

Dynamic XSL Style Sheet Engine

Pure Java

Using XML as the data or property interface between the JSP and the Bean increases the usability for the HTML/JSP developer. As an example, the bean might return a list of names and phone numbers from the database. If this data is formatted as XML, rather than as some proprietary data structure, then the JSP developer can simply apply a style sheet to format the data – say into an HTML table. The fact that all of the interfaces are based on standards increases the reusability of applications built with this paradigm. It also allows for shorter learning cycles and an increased amount of resources. Simply buy one of the dozens of books on any one of these technologies to learn more, or look for examples. HTML and Java development staffs will also be encouraged to use standard technology.

HTML and Java Developers Unite

Page 4 of 6

The dynamic XSL style sheet engine mentioned in the above diagram takes the idea of applying a style sheet to an XML document further. In the Bluestone Sapphire/UBS, this provides a mechanism to do client type sensing, as well as an XML-configured set-up for applying the right XSL style sheet for the appropriate client. For example, an IE5 browser can process XSL on the browser, so no style sheet needs to be applied on the server. However a Netscape V2 browser would need to have the server engine format the output in HTML for display. This becomes even more powerful as the client type expands into devices – where the XSL style sheet might format the output in WML for wireless devices, or VXML for voice-based devices. Chaining JSP’s JSP’s are typically developed to have an “input” page (like a form) and a “Results” page (like a catalog listing based on the fields filled out in the form). This is done with the tag. The “results” page typically contains the call to the bean. Within Bluestone’s Total-e-Business Storefront we have extended this basic idea to have a “processing” page between the “input” and “results” pages.

Input JSP

Process JSP

Results JSP

The “process” JSP would contain the calls to the business logic beans. This JSP can be viewed as an “object” that might be developed by the Java developers rather than the HTML/JSP developers. This not only eases the Java knowledge needed by the HTML/JSP people, but also increases the reusability. Developing Beans Most Java developers are comfortable with writing Java Beans or EJB’s by themselves with tools like Visual Café. However, there are emerging tools like Bluestone Visual-XML that provide pointand-click interface for creating Beans. The Bluestone Visual-XML tool has wizards that expose back-end data sources like databases, SAP and Mainframes. The wizards also create the logic and XML interface to the bean. It creates pure Java applications that have the added benefit of not having to write tedious JDBC code. In addition, the interface to the bean can be generic. This way, if the database changes, the bean can be updated graphically in the tool without affecting the JSP application.

HTML and Java Developers Unite

Page 5 of 6

Summary – HTML Developers and Java Developers Unite In summary, Java Server Pages have introduced a standard mechanism to write web-based applications. Similar to Microsoft’s Active Server Pages in the Microsoft world, it has brought a standard mechanism for the Java environment. JSP’s are easily accessible by most HTML developers today. They provide the perfect platform for the integration between HTML and Java/Database developers for small and large organizations. Bluestone’s new Total-e-Business product suite is developed on this open foundation. All of the Storefront and “MyStorefront.com” functionality use this methodology and provide a wealth of examples for both HTML and Java developers to use. References JSP Home Page http://java.sun.com/products/jsp/product.html JSP Syntax Quick Reference http://java.sun.com/products/jsp/syntax.pdf JSP – ASP Comparison http://java.sun.com/products/jsp/jsp-asp.html

HTML and Java Developers Unite

Page 6 of 6