Edit Edit

Java Servlet FAQ

How do you debug a servlet with jdb and the JavaServer Web Development Kit(JSWDK)?

1) Add "JSWDK\webserver.jar" to your CLASSPATH environment variable where JSWDK is the full path where you installed the JSWDK.

2) Copy your servlet's .class file to "JSWDK\examples\web-inf\servlets" and add "JSWDK\examples\web-inf\servlets" to your CLASSPATH so that jdb can locate your servlet's .class file.

3) In your JSWDK directory, create a "SETUPSERVER.BAT" file with a text editor and copy+paste from "JSWDK\startserver.bat" the lines that setup the environment variables for the Web server. If you're lazy, you can just copy+paste the following lines into your "SETUPSERVER.BAT" file:

rem ---------- start of SETUPSERVER.BAT ----------
set jsdkJars=.\webserver.jar;.\lib\jakarta.jar;.\lib\servlet.jar
set jspJars=.\lib\jsp.jar;.\lib\jspengine.jar
set beanJars=.\examples\WEB-INF\jsp\beans;.\webpages\WEB-INF\servlets;.\webpages\WEB-INF\jsp\beans
set miscJars=.\lib\xml.jar;.\lib\moo.jar
set appJars=%jsdkJars%;%jspJars%;%beanJars%;%miscJars%
set sysJars=%JAVA_HOME%\lib\tools.jar

set appClassPath=.\classes;%appJars%
set cp=%CLASSPATH%

set CLASSPATH=%appClassPath%;%sysJars%

if "%cp%" == "" goto next

rem else
echo Using classpath: %CLASSPATH%
rem ---------- end of SETUPSERVER.BAT ----------

4) Open a DOS command line window.

5) Change directory to the JSWDK directory


7) Run "jdb"

8) Set a breakpoint in your servlet. Type "help" for a list of jdb commands if you don't know how to set a breakpoint.

9) Type "run com.sun.web.shell.Startup" to run the Web server.

10) Open a Web browser and invoke your servlet. For example, use the URL:


Last updated 12/26/1999 05:27:46 PM