1.2 Support for Servlets

Java Servlet Programming, 2nd Edition > 1. Introduction > 1.2 Support for Servlets

 
< BACKCONTINUE >

1.2 Support for Servlets

Like Java itself, servlets were designed for portability. Servlets are supported on all platforms that support Java, and servlets work with all the major web servers.[1] Java servlets, as defined by the Java Software division of Sun Microsystems (formerly known as JavaSoft), are an Optional Package to Java (formerly known as a Standard Extension). This means that servlets are officially blessed by Sun and are part of the Java language, but they are not part of the core Java API. Instead, they are now recognized as part of the J2EE platform.

[1] Note that several web server vendors have their own server-side Java implementations, some of which have also been given the name servlets. These are generally incompatible with the Java servlets as defined by Sun. Most of these vendors are converting their Java support to standard servlets or are introducing standard servlet support in parallel, to allow backward compatibility.

To make it easy for you to develop servlets, Sun and Apache have made available the API classes separately from any web engine. The javax.servlet and javax.servlet.http packages constitute this Servlet API. The latest version of these classes is available for download from http://java.sun.com/products/servlet/download.html.[2] All web servers that support servlets must use these classes internally (although they could use an alternate implementation), so generally this JAR file can also be found somewhere within the distribution of your servlet-enabled web server.

[2] At one point it was planned for these classes to come bundled as part of JDK 1.2. However, it was later decided to keep the servlet classes separate from the JDK, to better allow for timely revisions and corrections to the Servlet API.

It doesn't much matter where you get the servlet classes, as long as you have them on your system, since you need them to compile your servlets. In addition to the servlet classes, you need a servlet runner (technically called a servlet container , sometimes called a servlet engine), so that you can test and deploy your servlets. Your choice of servlet container depends in part on the web server(s) you are running. There are three flavors of servlet containers: standalone , add-on, and embeddable.

1.2.1 Standalone Servlet Containers

A standalone servlet container is a server that includes built-in support for servlets. Such a container has the advantage that everything works right out of the box. One disadvantage, however, is that you have to wait for a new release of the web server to get the latest servlet support. Another disadvantage is that server vendors generally support only the vendor-provided JVM. Web servers that provide standalone support include those in the following list.

  • Apache's Tomcat Server, the official reference implementation for how a servlet container should support servlets. Written entirely in Java, and freely available under an open source license. All the source code is available and anyone can help with its development. This server can operate standalone or as an add-on providing Apache or other servers with servlet support. It can even be used as an embedded container. Along with Tomcat, Apache develops the standard implementation of the javax.servlet and javax.servlet.http packages. At the time of this writing servlets are the only java.* or javax.* packages officially maintained as open source.[3] See http://jakarta.apache.org.

    [3] Having a standard open source implementation of javax.servlet and javax.servlet.http has resulted in numerous helpful bug fixes (for example, Jason committed a fix to HttpServlet improving the behavior of conditional GET) and no incompatibility concerns. We hope this track record helps encourage more official Java packages to be released as open source.

  • iPlanet (Netscape) Web Server Enterprise Edition (Version 4.0 and later), perhaps the most popular web server to provide built-in servlet support. Some benchmarks show this server to have the fastest servlet implementation. Beware that, while Versions 3.51 and 3.6 of this server had built-in servlet support, those servers supported only the early Servlet API 1.0 and suffered from a number of bugs so significant the servlet support was practically unusable. To use servlets with Netscape 3.x servers, use an add-on servlet container. See http://www.iplanet.com.

  • Zeus Web Server, a web server some consider the fastest available. Its feature list is quite long and includes servlet support. See http://www.zeus.co.uk.

  • Caucho's Resin, an open source container that prides itself on performance. It can run in standalone mode or as an add-on to many servers. See http://www.caucho.com.

  • Gefion Software's LiteWebServer, a small (just over 100K) servlet container intended for uses, such as bundling with demos, where small size matters. See http://www.gefionsoftware.com/LiteWebServer.

  • World Wide Web Consortium's Jigsaw Server, open source and written entirely in Java. See http://www.w3.org/Jigsaw.

  • Sun's Java Web Server, the server that started it all. This server was the first server to implement servlets and acted as the effective reference implementation for Servlet API 2.0. It's written entirely in Java (except for two native code libraries that enhance its functionality but are not needed). Sun has discontinued development on the server, concentrating now on iPlanet/Netscape products as part of the Sun-Netscape Alliance. See http://java.sun.com/products.

Application servers are a growing area of development. An application server offers server-side support for developing enterprise-based applications. Most Java-based application support servlets and the rest of the Java 2, Enterprise Edition, (J2EE) specification. These servers include:

  • BEA System's WebLogic Application Server, one of the first and most famous Java-based application servers. See http://www.beasys.com/products/weblogic.

  • Orion Application Server, a high-end but relatively low-priced server, written entirely in Java. See http://www.orionserver.com.

  • Enhydra Application Server, an open source server from Lutris. See http://www.enhydra.org.

  • Borland Application Server 4, a server with a special emphasis on CORBA. See http://www.borland.com/appserver.

  • IBM's WebSphere Application Server, a high-end server based partially on Apache code. See http://www-4.ibm.com/software/webservers.

  • ATG's Dynamo Application Server 3, another high-end server written entirely in Java. See http://www.atg.com.

  • Oracle's Application Server, a server designed for integration with an Oracle database. See http://www.oracle.com/appserver.

  • iPlanet Application Server, the J2EE-compliant big brother to the iPlanet Web Server Enterprise Edition. See http://www.iplanet.com/products/infrastructure/app_servers/nas.

  • GemStone/J Application Server, a Java server from a company previously known for its Smalltalk server. See http://www.gemstone.com/products/j.

  • Allaire's JRun Server (formerly from Live Software), a simple servlet container that grew to an advanced container providing many J2EE technologies including EJB, JTA, and JMS. See http://www.allaire.com/products/jrun.

  • Silverstream Application Server, a fully compliant J2EE server that also started with a servlet focus. See http://www.silverstream.com.

1.2.2 Add-on Servlet Containers

An add-on servlet container functions as a plug-in to an existing server it adds servlet support to a server that was not originally designed with servlets in mind or to a server with a poor or outdated servlet implementation. Add-on servlet containers have been written for many servers including Apache, iPlanet's FastTrack Server and Enterprise Server, Microsoft's Internet Information Server and Personal Web Server, O'Reilly's WebSite, Lotus Domino's Go Webserver, StarNine's WebSTAR, and Apple's AppleShare IP. Add-on servlet containers include the following:

  • New Atlanta's ServletExec, a plug-in designed to support servlets on all the popular web servers on all the popular operating systems. Includes a free debugger. See http://www.servletexec.com.

  • Allaire's JRun (formerly from Live Software), available as a plug-in to support servlets on all the popular web servers on all the popular operating systems. See http://www.allaire.com/products/jrun/.

  • The Java-Apache project's JServ module, a freely available open source servlet container that adds servlet support to the extremely popular Apache server. Development has completed on JServ, and the Tomcat Server (acting as a plug-in) is the replacement for JServ. See http://java.apache.org/.

  • Apache's Tomcat Server, as discussed previously, Tomcat may be plugged into other servers including Apache, iPlanet/Netscape, and IIS.

1.2.3 Embeddable Servlet Containers

An embeddable container is generally a lightweight servlet deployment platform that can be embedded in another application. That application becomes the true server. Embeddable servlet containers include the following:

  • Apache's Tomcat Server, while generally used standalone or as an add-on, this server also can be embedded into another application when necessary. Because this server is open source, development on most other embeddable containers has stopped.

  • Anders Kristensen's Nexus Web Server, a freely available servlet runner that implements most of the Servlet API and can be easily embedded in Java applications. See http://www-uk.hpl.hp.com/people/ak/java/nexus/.

1.2.4 Additional Thoughts

Before proceeding, we feel obliged to point out that not all servlet containers are created equal. So, before you choose a servlet container (and possibly a server) with which to deploy your servlets, take it out for a test drive. Kick its tires a little. Check the mailing lists. Always verify that your servlets behave as they do in the Tomcat reference implementation. Also, you may want to check what development tools are provided, which J2EE technologies are supported, and how quickly you can get a response on the support lines. With servlets, you don't have to worry about the lowest-common-denominator implementation, so you should pick a servlet container that has the features you want.

For a complete, up-to-date list of available servlet containers, complete with current pricing information, see http://www.servlets.com.


Last updated on 3/20/2003
Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

< BACKCONTINUE >


Java servlet programming
Java Servlet Programming (Java Series)
ISBN: 0596000405
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net