ServletDebugger 2.0 works with your favorite Java development tool to tackle the tough job of debugging and stress testing Servlets. This tool eliminates the usual "code, compile, cross your fingers and test" method of Servlet construction. ServletDebugger is a Java 1.1-based library that works with a simple stub class allowing you to step through your Servlet code one line at a time. Servlets can be tested with GET and POST request types as well as unlimited init parameters, header values and form data. Additionally, ServletDebugger comes complete with a built-in Web server to test and debug your Servlet using your Web browser.
Normally at this point in a software product review, I'd be giving you a long list of requirements in order to make sure this product worked with your system. Since ServletDebugger is 100% pure Java, the only requirement is a JDK 1.1 Java Development tool that runs on your particular operating system. In my case, I installed it on Windows NT Server 4.0. The InstallShield setup worked without a hitch and included the servletdebugger.jar file, a sample project and documentation in Microsoft Word, HTML, RTF and PDF formats.
The documentation gives an overview of ServletDebugger's features and capabilities, how to use it with the included sample project and a short tutorial in Servlet development. Since the sample project and associated documentation refer to Symantec's Visual Café for Java, I will describe how to set up and use ServletDebugger with Borland's JBuilder 2.
In order to debug Servlets from within JBuilder, you must first make servletdebugger.jar available to the development environment. With JBuilder open, select the "Tools" menu and click on "Default Project Properties...." Click the "Add" button on the "Paths" tab. In the "Select a Java library to add" dialog, click "New." In the "Name:" field type in "ServletDebugger." Click the "..." button to the right of the "Class Path" field. At the bottom of the "Edit LibraryClassPath" dialog, click the "Add Zip/JAR" button. Use the "Add Zip/JAR" dialog to locate "servletdebugger.jar" from your file system. Once you've found the file, click "OK" at the bottom of the "Edit LibraryClassPath." Click "OK" at the bottom of the "Select a Java library to add" dialog. Click "OK" to exit the "Default Project Properties" window.
With the environment set, create an empty project in JBuilder and then add "SnoopServlet.java" and "SnoopServlet
Debugger.java" from the sample Visual Cafe project directory. At this point you can set breakpoints in the
"SnoopServlet.java" Servlet, as seen in Figure 1, and then begin debugging it by selecting the "Run" menu and clicking on "Debug."
ServletDebugger gives you two ways to debug your Servlets. The normalModeTest method runs the Servlet and sends the output to the error stream System.err. The serverModeTest method uses a built-in HTTP server to allow you to submit multiple requests to your Servlet from your browser. From there you also have access to the Servlet Stress Tester shown in Figure 2 which allows you to GET and POST Form data to your Servlet for further debugging and performance analysis.
Now that Servlets have really taken off, ServletDebugger 2.0 fills a widespread debugging and performance testing need. You can now step through your code in the same way that you would if you were debugging a Java application. I think the documentation could use some beefing up in the areas of sending different request types to your Servlet using the normalModeTest method. Seasoned Java developers should have no trouble figuring things out, but a novice might. All in all, I find ServletDebugger 2.0 to be a great product that I personally find indispensable when it comes to building professional Web sites.
About the Author
Robert Tiffany is a Senior Technology Consultant
with Insource Technology in Houston, TX. He can
be reached at [email protected]