Debugging Java Server Pages has the same basic requirements and setup as debugging Java servlets. Take a look at the servlet debugging page for launching your application server with debugging support enabled.
Debugging servlets is quite straightforward in terms of setting the sourcepath, but JSP pages are a little different. To permit source-level debugging, it is necessary to determine what the application server considers to be the sourcepath of the JSP pages. Typically this is the document root of your web application.
One way to determine the exact sourcepath setting to use for
your JSP pages is to use the source command. This
takes the name of a loaded class, finds the class in the debuggee,
and displays the source-related information. Included in the output
is the Source paths value, which shows the path to
the source file. The sourcepath setting should include the path
leading up to, but not including, that "source
path". It is important not to confuse this JPDA terminology
with the JSwat term of the same name.
As of version 2.33, the default value for the JSwat
"Default Source Stratum" in the Preferences dialog is
blank. Previously it was "Java", which would be quite
wrong for use when debugging JSP pages. Be sure to check this value
and set it to blank or "JSP". If you set it to blank,
then the default stratum of the debuggee will be used, which
results in the appropriate stratum being used for each class. This
is useful since it results in getting the .java source
for servlets and the .jsp source for JavaServer Pages
pages. Note that the 3.x versions of JSwat do not yet provide a
means of setting the default stratum.
Debugging JSP pages deployed in Tomcat is generally quite easy. Start by getting the latest version of Tomcat, which should be at least version 5.0. Earlier releases may have had a different layout, and these instructions may not be appropriate for those versions.
Once you have started Tomcat with debugging support enabled, and
connected JSwat to Tomcat, you should load your JSP page in a web
browser to force the servlet code to be generated. The generated
servlet class name will have the prefix org.apache.jsp
and should be visible in the Classes tree. If you double-click on
the name of a generated servlet class, the source for the JSP page
should be displayed, assuming the sourcepath is set correctly. From
there you can set breakpoints and step through the JSP source as
usual.
If for whatever reason you wanted to debug the Tomcat JSP
examples, you must comment out or remove the <servlet> and
<servlet-mapping> definitions for the example JSP pages in
the webapps/jsp-examples/WEB-INF/web.xml file, then
restart the Tomcat server. The sourcepath setting for the examples
web application would be webapps/jsp-examples
(including the path leading to that directory), found in the Tomcat
installation directory.