This document is also available in Serbo-Croatian language. Thanks to Anja Skrba for translating it!In order to run your servlets, JSPs and Java web applications you need a "servlet container". A servlet container is a piece of software which runs on a computer connected to a network, and processes incoming page requests, turning them into generated pages. In many ways a servlet container is similar to a web server, like Apache or IIS, and indeed several servlet containers will also function as a web server if required. Some servlet containers are designed to work best in conjunction with a separate web server, some are designed to work best "stand alone", and some will work just as effectively either way.
You can get and run a servlet container providing pages to the internet in several ways:
- The simplest way is when one comes ready-installed as part of the web space and bandwidth you rent from a hosting company. Usually, if a hosting company offers servlet/JSP features, they will make it fairly obvious on their plans or products page. See our Java Web Hosting Companies list for details and recommendations of some of the hosting companies I've had experience of that offer JSP, servlet, and/or web application hosting facilities.
- Other hosting companies might not offer a Java servlet container as a standard feature, but might offer it as an optional upgrade, or maybe allow you to install and manage your own web server or servlet container software within the space and bandwidth you rent from them. If you spot a hosting company you like, it certainly doesn't hurt to ask them if they allow this, and the answers you get can be a good indicator of the level of service they offer to customers.
- If you have your own computer connected to the internet using an "always on" connection such as DSL or a cable modem, you may be able to run a web server and/or a servlet container on your home PC, and make your JSPs, servlets and web applications available to the internet that way. Be careful to check the agreement with your access provider, though. Some specifically prohibit running a public server on this sort of connection, and you don't want to find yourself suddenly cut off from the 'net.
- If you are comfortable with system admin tasks, you might consider renting a "dedicated" server machine in a rack in some huge warehouse. This can vary enormously in cost per month and features, but the bottom line is that you are responsible for setting up your own software. With a "dedicated" server, the company you rent it from will normally take care of any hardware problems, but if you screw up the configuration you will have to sort it out yourself. You will, almost certainly, have to install and manage your own servlet container software.
- The last, most risky, but most flexible, option is to buy or build and configure your own machine, then ship it to one of those internet-connected warehouses for a "colocation" arrangement. With colocation you rent the services of the building (rack space, power, air conditioning, internet bandwidth) for your own machine. This is the route of choice if you are completely happy with building a server machine, then configuring and maintaining it remotely. Remember you can't just reboot it or jiggle a loose connector if it's in a secure facility 100 miles away!
Whichever route to putting your Java code on the web you choose, you would do well to understand the differences between the different available servlet container software. That way you can both evaluate hosting offerings that include Java as standard, and choose which software to install if you plant to do it yourself. Here is a selection of some of the major current players. I'll try to keep this list as up-to-date as I can, but software is always a moving target. If you spot anything missing or which is glaringly out of date, please let me know.
|Resin 2.1||Servlet: 2.3 JSP: 1.2 Cost: Free/$500 Source: yes|
I use Resin 2.1 for most of my Java web development at the moment. It's well-written, well supported, and above all fast. It's quick to start up, reliably detects hot-deployed web-application "war" files and does its best to give sensible error messages when things go wrong, which makes it great for use during development. Luckily, it's also free for development and experimentation. You only need to pay for a licence if you (or your employer) is making money out of using Resin.
Resin will play nicely as an extension to a web server, but generally performs even better when used "stand-alone".
Although Resin 2.1 is still being maintained, that's only to cover bugfixes and security updates. If you need features from Servlets 2.4 or JSP 2.0, you should probably look at Resin 3, instead.
|Resin 3.0||Servlet: 2.4 JSP: 2.0 Cost: Free/$500 Source: yes|
Some fairly major changes were needed from the Resin 2.1 code base to support the new features of Servlets 2.4 and JSP 2.0, so a whole new version of Resin was produced. Resin 3.0 only came out of beta in September 2003, and although it is production-quality, it is still changing fairly regularly. It doesn't help that the Servlet 2.4 and JSP 2.0 APIs are still only at the "final draft" stage. Note also that changes in the specification for things like deployment descriptors between Servlets 2.3 and Servlets 2.4 may mean that web applications written for the 2.3 API may need minor "tweaking" to work with this container.
That said, if you are starting a new Java web project, this would likely be a good container to build it with. The new APIs will become the defacto standard soon enough, and there's little point limiting your options and ignoring all the neat new features.
|Tomcat 4||Servlet: 2.3 JSP: 1.2 Cost: Free Source: yes|
Tomcat is the "reference implementation" of the Servlet and JSP APIs. What this is supposed to mean is that if an area of the written specification is ambiguous or unclear, the way that Tomcat implements it defines the way it should work. In practice this seems sometimes to be taken as meaning that Tomcat can ignore or redefine the specification, much to the irritation of other container writers who struggle to implement the exact letter of the spec.
Tomcat 4 is the current production release of Tomcat. There is a Tomcat 5, which implements the Servlet 2.4 and JSP 2.0 APIs, but that is currently still only a beta release. Tomcat is free for both commercial and development use, which is why it is popular with hosting companies, but it can seem clumsy and sometimes slow compared with some other servers. Personally, I don't like Tomcat much for use during development, it is not very good at monitoring a directory and hot-deploying or hot-updating web applications, instead relying on a web service to tell it what is new. This shouldn't matter too much on a live server, where application deployment or update is relatively rare, though. Although Tomcat will work as a stand-alone web server, it seems to be primarily designed to work as an extension to a web server such as Apache.
|Jetty 4||Servlet: 2.3 JSP: 1.2 Cost: Free Source: yes|
|Jetty is another major player in the free servlet container game. Jetty has the advantage of being generally small and fast, and is particularly suited to stand-alone applications, or as an embedded web server to provide a web interface to another project.|
|bjServer||Servlet: 2.3 JSP: 1.2 Cost: Free Source: no?|
|Notthing like as well known as the "big boys", but definately worth a download. This is one of the few servlet containers that can run web applications straight from a "war" file without extracting them to a filesystem first. I use it as a test case to make sure that my web applications run in the full range of containers. bjServer is already fast and small, and the author is continually improving this software.|