1.2. Download a Server for Your Desktop

Your second step is to download a server that implements the Java Servlet 2.3 and JSP 1.2 specifications for use on your desktop. In fact, I typically keep two servers installed on my desktop (Apache’s free Tomcat server and one commercial server) and test my applications on both to keep myself from accidentally using nonportable constructs.

Regardless of the server that you will use for final deployment, you will want at least one server on your desktop for development. Even if the deployment server is in the office next to you connected by a lightning-fast network connection, you still don’t want to use it for your development. Even a test server on your intranet that is inaccessible to customers is much less convenient for development purposes than a server right on your desktop. Running a development server on your desktop simplifies development in a number of ways, as compared to deploying to a remote server each and every time you want to test something.

  1. It is faster to test. With a server on your desktop, there is no need to use FTP or another upload program. The harder it is for you to test changes, the less frequently you will test. Infrequent testing will let errors persist that will slow you down in the long run.

  2. It is easier to debug. When running on your desktop, many servers display the standard output in a normal window. This is in contrast to deployment servers where the standard output is almost always either completely hidden or only available on the screen of the system administrator. So, with a desktop server, plain old System.out.println statements become useful tracing and debugging utilities.

  3. It is simple to restart. During development, you will find that you need to restart the server frequently. For example, the server typically reads the web.xml file (see Chapter 4, “ Using and Deploying Web Applications ”) only at startup. So, you normally have to restart the server each time you modify web.xml. Although some servers (e.g., ServletExec) have an interactive method of reloading web.xml, tasks such as clearing session data, resetting the ServletContext, or replacing modified class files used indirectly by servlets or JSP pages (e.g., beans or utility classes) may still necessitate restarting the server. Some older servers also need to be restarted because they implement servlet reloading unreliably. (Normally, servers instantiate the class that corresponds to a servlet only once and keep the instance in memory between requests. With servlet reloading, a server automatically replaces servlets that are in memory but whose class file has changed on the disk). Besides, some deployment servers recommend completely disabling servlet reloading in order to increase performance. So, it is much more productive to develop in an environment where you can restart the server with a click of the mouse without asking for permission from other developers who might be using the server.

  4. It is more reliable to benchmark. Although it is difficult to collect accurate timing results for short-running programs even in the best of circumstances, running benchmarks on systems that have heavy and varying system loads is notoriously unreliable.

  5. It is under your control. As a developer, you may not be the administrator of the system on which the test or deployment server runs. You might have to ask some system administrator every time you want the server restarted. Or, the remote system may be down for a system upgrade at the most critical juncture of your development cycle. Not fun.

Now, if you can run on your desktop the same server you use for deployment, all the better. But one of the beauties of servlets and JSP is that you don’t have to; you can develop with one server and deploy with another. Following are some of the most popular free options for desktop development servers. In all cases, the free version runs as a standalone Web server; in most cases, you have to pay for the deployment version that can be integrated with a regular Web server like Microsoft IIS, iPlanet/Netscape, or the Apache Web Server. However, the performance difference between using one of the servers as a servlet and JSP engine within a regular Web server and using it as a complete standalone Web server is not significant enough to matter during development. See http://java.sun.com/products/servlet/industry.html for a more complete list of servers.

  • Apache Tomcat. Tomcat 4 is the official reference implementation of the servlet 2.3 and JSP 1.2 specifications. Tomcat 3 is the official reference implementation for servlets 2.2 and JSP 1.1. Both versions can be used as a standalone server during development or can be plugged into a standard Web server for use during deployment. Like all Apache products, Tomcat is entirely free and has complete source code available. Of all the servers, it also tends to be the one that is most compliant with the latest servlet and JSP specifications. However, the commercial servers tend to be better documented, easier to configure, and a bit faster. To download Tomcat, see http://jakarta.apache.org/tomcat/.

  • Allaire/Macromedia JRun. JRun is a servlet and JSP engine that can be used in standalone mode for development or plugged into most common commercial Web servers for deployment. It is free for development purposes, but you have to purchase a license before deploying with it. It is a popular choice among developers that are looking for easier administration than Tomcat. For details, see http://www.allaire.com/products/JRun/.

  • New Atlanta’s ServletExec. ServletExec is another popular servlet and JSP engine that can be used in standalone mode for development or, for deployment, plugged into the Microsoft IIS, Apache, and iPlanet/Netscape Web servers. Version 4.0 supports servlets 2.3 and JSP 1.2. You can download and use it for free, but some of the high-performance capabilities and administration utilities are disabled until you purchase a license. The ServletExec Debugger is the configuration you would use as a standalone desktop development server. For details, see http://www.servletexec.com/.

  • Caucho’s Resin. Resin is a fast servlet and JSP engine with extensive XML support. It is free for development and noncommercial deployment purposes. For details, see http://www.caucho.com/.

  • LiteWebServer from Gefion Software. LWS is a small standalone Web server that supports servlets and JSP. It is free for both development and deployment purposes, but a license will entitle you to increased support and the complete server source code. See http://www.gefionsoftware.com/LiteWebServer/ for details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.86.183