A Web Application is a collection of server-side technologies for presenting dynamic content, usually accessed by a Web browser on the client side. In the platform-independent Java world, it is some combination of Java Server Pages (JSP files), servlets, applets, HTML (or XHTML), XML, Java classes, images, and other resources.
The Java 2 Platform, Enterprise Edition (J2EE) provides the core APIs and architecture for a component-based, platform-independent Web applications. A J2EE based application server will include a Web container that is responsible for managing the lifecycle of servlets and JSPs. This Web container might be integrated into the Web server, or may be an add-on or plugged in to the Web server. The reference implementation of the Web container for the Servlet 2.3 and the JavaServer Pages 1.2 Specification is Tomcat 4. webAF includes Tomcat, which is pre-configured to make it easy to develop and test Web applications in an integrated development environment (IDE).
Servlets are Java classes that receive requests and write responses, usually using the HTTP protocol. Often the response will be a dynamically-generated HTML page, though other content types such as XML, applets, or serialized java objects can also be output. The Web container passes requests to the servlet and receives its response through a well-defined API, and the servlet container is responsible for creating and destroying the servlet.
JavaServer Pages are an extension of servlet technology. In fact, JavaServer Pages are compiled into servlets and executed on-the-fly by the Web container. Unlike a serlvet, which is composed by the developer as a Java source file, the JSP file resembles HTML, perhaps with sprinklings of embedded Java source code. In practice, the decision on whether to develop a Web page using a servlet or JSP (or a combination of both) will often depend on the content. A JSP is best suited as a "view" component, especially for pages that are composed of mostly static HTML. The servlet is better suited as a "controller" or "model" component, and often implements the business logic or serves as an interface to the business logic. webAF includes Struts, an open-source framework for building flexible Web applications using a combination of JSP files and servlets.
Besides servlets and JavaServer Pages, a Web application may include lots of other static resources such as ordinary HTML pages, image files, XML configuration files, and properties files. An advantage of a J2EE Web application is that the entire Web application can be bundled into a single Web Application Archive (WAR) file. This WAR file can then be deployed to a different J2EE-compliant Web server without modification. A single webAF command will generate the WAR file for you.
JavaServer Pages (JSP) technology makes it easier to build Web pages with dynamically generated content through the use of Java's component-based technology. It separates the user interface from the application logic, which enables
Java is the native scripting language for JSP, which means you can develop platform-independent applications due to Java's "Write Once, Run Anywhere" characteristic. In the simplest terms, a JSP is simply an HTML page with embedded Java code.
If you are comfortable writing Java code, you can embed Java programs directly in the JSP using scriptlet tags. If you're not a programmer, you can take advantage of reusable, cross-platform components (JavaBeans or Enterprise JavaBeans components) with JSP-specific XML tags that make it simple to instantiate JavaBean components and manipulate properties on a component from within your Web page.
Through the use of this component-based logic, page developers are able to develop sophisticated, interactive web-based applications with very little Java programming knowledge. Many vendors, including SAS Institute Inc., offer JavaBean components that encapsulate complex logic that would be difficult and time-consuming for a Web page developer to code themselves.
To summarize the process that creates and executes a JSP:
For more information on JSP technology and what it has to offer, see java.sun.com/products/jsp/index.html
Prior to JSP, Web developers were forced to select proprietary alternatives to incorporate dynamic content within their Web pages. JSP is designed to be an open, industry-standard method that supports numerous servers, browsers, and development tools. Using JSP, page authors can implement their Web pages using the tools or interfaces they already know. For example, Web site designers can use their favorite HTML authoring tool for the overall design of the page. At the same time, complex server-side processing can be incorporated into the page using JavaBeans or Enterprise JavaBeans that are available from a large number of software vendors.
JavaServer Pages provide other benefits as well. Execution of JSPs is simple and fast because they can be executed on any Java-enabled Web server, application server, or operating system. This differs from other technologies that have specific server requirements. For example, Microsoft's Active Server Pages (ASP) technology relies on other Microsoft technologies and Web servers.
JSP also holds advantages over traditional CGI-based solutions, which have shown limitations with respect to scalability. With each CGI request, a new process on the server is launched. When multiple users access the program concurrently, these processes can quickly consume all of the Web server's available resources, which brings the applications to a halt. When a JSP is first called, if it does not yet exist, it is compiled into a Java Servlet class and stored in the server memory. A Java Servlet is a Java technology-based program that runs on the server as opposed to an applet, which runs on the browser. This enables very fast responses for subsequent calls to that page (and avoids the CGI-bin problem of spawning a new process for each HTTP request, or the run-time parsing required by server-side includes).
Finally, JSP differs from other technologies because it utilizes reusable components and tags, instead of relying heavily upon scripting within the page itself. And through its use of servlet technology and Java server-side processing, it offers