One of the new features of Jasper in Tomcat 5 is that it attaches a "Source Map" attribute to class files to describe the file name and line number mapping from a JSP source file to the generated Java source file. The SMAP that I see in the class files generated by Jasper (5.0.3 alpha) has a couple of small problems: 1. The second line of the SMAP, according to JSR-45, is the name of the generated source file. This name should be without path information, but path information appears in the version generated by Jasper. 2. In the "*F" section, there's a pair of lines that defines the JSP file. The second line is the source path for the JSP file. The path created by Jasper contains a leading slash, making it an absolute path. It should be relative; the leading slash should not appear.
The second line of the SMAP contains path information on Windows machines because SmapUtil.java's generateSmap() method calls unqualify() to remove the path information, and unqualify() only works on pathname strings with "/" as the name-separator character. I fixed this by rewriting unqualify(). The leading slash in the source path in the "*F" section originates deep within Tomcat (for instance, in a call to HttpServletRequest.getServletPath() when the request is first touched), so I chose to remove the leading slash just before writing the source path to the SMAP. I will attach a patch containing these fixes.
Created attachment 7441 [details] Proposed patch
Applied patch with slight modification: Instead of (as suggested in the patch): private static String unqualify(String path) { File f = new File(path); return f.getName(); } the impl now does this: private static String unqualify(String path) { return path.substring(path.lastIndexOf(File.separator) + 1); } which avoids generation of a File object.