|
JspDebugging
Guidelines for debugging JavaServer Pages
The BasicsDebugging 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 in JSwat. 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. Apache TomcatDebugging 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. Then follow the steps described on ServletDebugging under the Apache Tomcat heading to start Tomcat with debugging enabled and connect JSwat to it. 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. Debugging the Examples 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.
|
It's a good thing you are NOT telling us how to start Tomcat with debugging enabled, and, especially, how to connect it with JSwat, it makes our lifes all the more adventurous...
@bobu... Sorry about that, originally the content on this page and the servlet debugging page were together on one page. During one of the many moves from one hosting site to another they apparently were split apart and I didn't notice the gap. Thanks for pointing it out.