|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3. JSP Technology: The Next Evolution of Servlets
JSP technology is a means for creating dynamic Web-based content using server-side (middle-tier) processing. JSP simplifies the process of creating these dynamic pages by separating the application logic from the page design and encapsulating logic in portable, reusable Java components.
JSP technology has evolved from the powerful servlet technology. (Servlets are Java technology-based, server-side applications.) JSP extends the servlet technology in many ways, making it easier and faster to build, deploy, and maintain server-side applications that communicate with Web-based clients. The following sections describe where JSP technology fits in the Java family of products, how JSP can simplify the creation and maintenance of dynamic pages, and how these pages fit into more complex, multitier applications.i
Overview of the Java APIs
The name Java is attached to many things, so it's worth cutting back to fundamentals for a moment and defining where JSP technology fits in the Java technology family of products.
A Java programming environment consists of the Java programming language, a Java language compiler (to compile the Java programs), and a Java virtual machine (to run the programs). The power of Java technology for cross-platform development lies in this model -- the compiler creates platform-independent executables (Java bytecode) that run in the Java virtual machine, which generates the actual, machine-specific instructions to execute.
Write Once, Run Anywhere
The underlying design goal driving all past and future Java development is articulated in the slogan, Write Once, Run Anywhere. The concept behind the technology is that any Java program can run on any Java virtual machine - without platform-specific modification. Because Java virtual machines are available for almost every platform, this is the closest thing possible to a universal programming environment.
The Java APIs
The Java programming language consists of classes and interfaces, accessible through defined APIs (application programming interfaces), distributed in a tree structure of class libraries. The Java core classes include the primary APIs. Extensions to the language are implemented through Java standard extensions.
JavaServer Pages Technology
JSP technology is implemented as a Java API; the JSP API is part of the Java 2 Platform, Enterprise Edition (J2EE). Because pages created with JSP actually compile into servlets, they build on and extend the servlet API as well. Because JSP technology is part of the J2EE platform, expect to see more servers and tools supporting this API. For more information on the latest version as well as a listing of the Web servers, application servers, and tools that support it, please go to java.sun.com/products/jsp/.
JSP Extends Servlets
In a sense, JSP technology does not provide new core technologies - everything that can be done with a JSP page, can also be done by writing a servlet. Servlets have access to the same set of Java APIs as JSP. Pages created with JSP technology are, in fact, compiled into servlets, so they cannot be capable of anything inherently different.
What JSP pages do, however, is enable a different, more efficient development methodology and simplify ongoing maintenance. This is because JSP technology truly separates the page design and static content from the logic used to generate the dynamic content.
Empowering Page Authors
Other methods for creating dynamic content require Web developers (with programming expertise) to embed the fixed page design and content into a script or a program (such as a CGI program). Average, HTML-literate page authors cannot easily edit and manipulate the content of the page without being familiar with the scripting language used.
With JSP technology pages, however, the logic itself is embedded in a standard page (HTML or XML). Page authors can use familiar tools to create and edit pages, and simply embed calls to the necessary application components where needed. All they need to know is how to invoke the logic - a programmer can be responsible for building and maintaining the logic components.
From a page author's perspective, the JSP page is a functionally-enhanced version of something they already know.
Benefits to Development Cycles
JavaServer Pages technology enables efficiencies in development and maintenance processes alike:
- Developers focus on the core components called by the pages. These components may be implemented through JavaBeansTM components or custom JSP tag libraries. Multiple applications can reuse the same components.
- Page authors can change the look and feel of a dynamic page, embed new content, update copyright information, change product names - all without involving the developer or interfering with the function of the page. Developers do not have to be involved in any routine page maintenance activities unless they involve application logic itself.
Not only does this division translate into faster application deployment, it makes the ongoing maintenance of these applications much easier by dividing the maintenance tasks themselves into content and logic tasks. In a sense, JSP technology keeps the code out of the content, and the content out of the code. Custom Tag Libraries Distribute Business Logic JSP technology supports a unique feature called Custom JSP Tags. Using this feature, a developer using the Java language could create a custom tag library of commonly-used functions, then distribute the information to a wide range of page authors. Instead of being responsible for every page's look and feel, the programmer is responsible solely for the application logic.
Custom tag libraries provide developers with an easy way to distribute sophisticated application functionality for reuse to a wide range of page authors. Because these tags are resolved in the server and not exposed to clients, they do not introduce client-side dependencies.
![]()
Web Page Designed By : Cheng-chien Yu Attaendant Class : Santa Monica College - CIS 36H Due Date : September 29, 2001.