Level: Introductory Paul Monday (pmonday@home.com), Senior Software Engineer, Imation Corp.
01 Jun 2001 Paul Monday, author and software engineer at Imation Corp., serves up the new features that JSP 1.2 sports, details how JSP technology is used to build reusable component libraries, and outlines JSP technology's place in the coming Web services revolution.
Two years ago, JSP pages were introduced to the Java programmer community as a way to bring dynamic content and programmatic-like function to the Web browser.
One year ago, JSP pages evolved to bring reusable components, known as tag libraries, into developer hands. With tag
libraries, programmers can build tags that Web developers use to invoke actions while at the same time buffering Web developers from changes in the underlying tag support (either sheltered from developer changes to the code or even from changes to the JSP specification itself). Tag libraries go well beyond the first generation of JSP pages, which largely centered on JavaBean interactions.
The present (and this year's JavaOne conference) comes with another year of growing up for the specification and JSP capabilities. Over the past several days, I have immersed myself in all things JSP and it is clear that JSP pages are a pivotal player in the coming Web services revolution.
Sessions on JSP detailed the new JSP 1.2 specification, the underlying Java Servlet 2.3 specification, and how JSP plays a role in Web services, the Java Enterprise Edition answer to Microsoft's .NET platform.
In this article, I'll touch on the new features that JSP 1.2 brings to the table, how JSP is being used to build reusable component libraries, and where JSP fits into the coming Web services revolution.
The technology
Simply put, JSP pages enable Web developers to add predefined actions and capabilities to their Web content. When a Web page is accessed that contains JSP tags, the Web page is generated into a servlet (on the first hit), the servlet is executed, and output is produced. In the past, JSP pages were essentially tags that were added to an HTML-based page. The output of the servlet was a complete HTML page that the browser accepted and the user could interact with. JSP 1.2 changes all of that.
Riding atop the changes to the underlying servlet architecture, the new JSP 1.2 specification formally recognizes that XML plays a heavy role in Web services. JSP pages can now be authored as full XML documents. Also, additions to the JSP and servlet specifications make it possible to create tag libraries that provide a robust user interface, as well as tag libraries that are coupled with the ability to extract data from back-end databases.
Let's cover some of the updates that are a part of the Servlet 2.3 specification, as well as some of the major updates to JSP technology for version 1.2 of the JSP specification. These updates allow developers to build onto the JSP base and produce robust, reusable tag libraries, frameworks, and Web services.
The reference implementation for the Servlet 2.3 and JSP 1.2 specifications is available in the open-source, free, Tomcat 4.0 implementation available from Apache.
Servlet 2.3 updates
Among many iterative changes in the servlet specification are two specific changes that have a large impact on the purpose of, and how you use, servlets:
Filters are a mechanism for intercepting and modifying requests and responses. The uses of filters can vary from blocking particular users or identities to transforming content after it is output from the servlet itself.
Filters are a formal part of the Servlet 2.3 specification. Within the new servlet packages, look for the Filter, FilterChain, and FilterConfig classes.
Event handling delivers the ability for a client to listen for a variety of page life-cycle events and HTTP request events. The event mechanism looks toward Web applications and the activities that are vital to controlling a Web application.
The first set of events that can be handled in servlets relates to the start-up and shutdown of servlets and changes in context attributes. The second set of events relates to HTTP sessions. With the events that can be intercepted by the HTTP event handling, you can watch:
- Creation and invalidation of HTTP contexts
- Changes in session attributes
- Migration of contexts from container to container
Like the filters, to get a "handle" on the new ability to handle events that relate to servlets and sessions, look to the Servlet 2.3 specification.
JSP 1.2 updates
JSP technology inherits the changes to the Servlet specification by the nature of the generative programming that turns JSP pages into servlets under the covers. The servlet capabilities become a major part of delivering new tag libraries and capabilities to users. In addition to the inherited changes from servlets, formal XML support is perhaps one of the biggest additions to the JSP specification.
I don't think anyone can argue that today, when you talk about Web services, XML is one of the major workhorses that enable those Web services. Prior to JSP 1.2, JSP supported XML by allowing JSP pages to generate XML data or be placed with XML streams themselves.
With JSP 1.2, the JSP page itself becomes a well-formed XML document. XML support goes further than just the JSP pages; XML is being woven into the structure of tag libraries to help with meta-data information for the tag libraries.
By becoming fully XML-compliant, JSP becomes a far easier specification to integrate into toolsets. It also becomes intertwined, and in some cases inseparable, from the whole Web services initiative.
There are other iterative changes to the core JSP specification, but in many ways the changes to JSP that are most important are those that are occurring above the core JSP specification.
Building onto the base
Besides the substantial changes to the JSP and servlet bases that I mentioned earlier, there are a large number of updates to the inner workings of JSP.
In my opinion, JSP is becoming somewhat like the Java platform itself. A community of developers is building atop the core technology. These additions, in the form of standardized tag libraries, frameworks, and Web services, are what will propel JSP into the enterprise space and into programmers' rapid application development toolkits.
In many ways, JSP can be compared to the Java platform, with tag libraries playing the crucial role for JSP that extension libraries play in the Java platform.
Tag libraries
I spoke with fellow developers about JSP pages and one common theme emerged: companies spend resources on developing common components, frequently user interfaces, which other developers within the company then build upon.
The capability for building tag libraries really came in JSP 1.1, but as of this conference, tag libraries are common and robustly used. In the next year, you are going to see communities and products form around tag libraries.
There are several JSRs to watch from Sun Microsystems that help seed the evolving tag library market. Among the JSRs that are working their way through the community process that involve tag libraries:
-
JSR 97: JavaHelp, formalization of the JavaHelp specification for use from JSP pages.
-
JSR 114: RowSet, helping to extract and present data from databases.
-
JSR 128 and JSR 126: JESI and Distributed Page Assembly help bring what could be considered a four-tier model to JSP pages. These two JSRs revolve around the ability to cache and use data nearer the client, thus alleviating traffic and server load.
The JSRs are remarkable in what they represent, rather than any huge technical challenges that they may or may not be solving. The core JSP model is stabilizing, much like the Java platform itself has stabilized. Services and capabilities are now exploding on top of the JSP specification which will make rapid application development possible in the J2EE space.
One of the greatest challenges facing individual companies that develop with JSP pages is the difficulty in developing browser-based user interfaces. A lot of resources in a development shop go toward developing tag libraries that present the user interface to a browser (and thus, the client). All of the developers I've talked to about this echo a common theme -- one or more developers build a common look-and-feel and turn it into a tag library for other developers to use for representation of data and user interface.
JavaServer Faces, JSR 127, changes this process. With JavaServer Faces, a common user interface infrastructure (developed at Sun) is handed to developers in the form of tag libraries, which developers can then reuse and customize to be their own. Not only does this help break down the barrier to full acceptance of JSP pages, it helps tool vendors to support JSP pages within their IDEs and application development suites.
The end is only the beginning
When I got on the plane for JavaOne and the JSP sessions, I expected to see simple updates on the usage of tags.
What I saw after I landed (at the show) was that JSP is evolving to a pivotal standard that will make offering Web services from the Java platform a reality.
The complete acceptance of XML into the authoring of JSP pages makes it easier to integrate JSP pages into Web-building applications. It also provides essential meta-data to the JSP pages and tag libraries so tag libraries become an efficient and standardized means of reusing code.
Last year, tag libraries made JSP pages usable and versatile for developers. This year, the proliferation of tag libraries and standards will make possible efficient use of JSP pages when building Web interfaces and interacting with data, through such projects as JavaServer Faces and a myriad of community processes that may be smaller in scope (like JSR 114 bringing RowSets to the JSP community), but no less important to the overall Web services strategy.
JSP pages have grown up and are now an essential piece of the future of the Java platform. Keep track of this technology; it is no longer a relatively Web-centric niche that demands little attention. There will be JSP pages in your future.
Resources - IBM offers a JSP 1.0 programming reference that comes complete with sample JSP 1.0 files, IBM extensions and additions to JSP 1.0 syntax, and a tutorial on how to use scripting languages in JSP 1.0 files.
- Donald Bell offers thoughts on how to use the Translator pattern in a JSP technology and servlet environment (developerWorks, February 2001).
- Here is Sun's central resource for JSP technology.
- The Java Community Process page offers PDFs of the Java Servlet 2.3 and JavaServer Pages 1.2 Specifications (Proposed Final Draft 2).
-
Tomcat is the official Apache reference implementation for JSP technologies.
- These articles, written by developers, provide details from JavaOne 2001 on various sessions and technology topics:
About the author  | |  | Paul Monday is a Senior Software Engineer at Imation Corp. working with the Jiro technology and storage appliances. He has an MS in Computer Science from Washington State University and has been published in JavaReport and in the Cutter IT Journal. He is coauthor of SanFrancisco Component Framework: An Introduction, published by Addison Wesley, and is author of the upcoming book The Jiro technology Programmer's Guide and Federated Management Architecture, also published by Addison Wesley. Contact Paul at pmonday@home.com. |
Rate this page
|