You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/02/27 18:59:52 UTC
DO NOT REPLY [Bug 27300] New: -
SMAP line numbers incorrect when JSP comments are present
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27300>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27300
SMAP line numbers incorrect when JSP comments are present
Summary: SMAP line numbers incorrect when JSP comments are
present
Product: Tomcat 5
Version: 5.0.19
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Jasper
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: robw@ensemble-systems.com
If a JSP contains JSP comments, the generated servlet does not contain the JSP
comments. Consequently, the SMAP line mappings are incorrect.
For example, given a JSP:
<html>
<head>
<title>Untitled Document</title>
</head>
<%--
JSP comment
--%>
<body>
</body>
</html>
The relevant section of the generated servlet (lines 42 to 49, inclusive) is:
out.write("<html>\n");
out.write(" <head>\n");
out.write(" <title>Untitled Document</title>\n");
out.write(" </head>\n");
out.write(" \n");
out.write(" <body>\n");
out.write(" </body>\n");
out.write("</html>");
And the Generated SMAP is:
SMAP
test_jsp.java
JSP
*S JSP
*F
+ 0 test.jsp
test.jsp
*L
1,8:42
*E
The fix requires the following two modications:
1) In the class org.apache.jasper.compiler.TextOptimizer, the overriden method
visit(Node.Comment n) must be removed.
2) The inner class org.apache.jasper.compiler.Generator.GenerateVisitor must
override the method visit(Node.Comment n). I tested this, using the following
code, which works correctly:
public void visit(Node.Comment n) throws JasperException {
n.setBeginJavaLine(out.getJavaLine());
out.printin("out.write(\"<%--");
String text = n.getText();
boolean newLine = false;
if (text != null) {
for (int i = 0; i < text.toCharArray().length; i++)
{
if (newLine) {
out.printin("out.write(\"");
}
char ch = text.charAt(i);
if (ch == '\n') {
out.println("\\n\");");
newLine = true;
}
else {
out.print(ch);
newLine = false;
}
}
}
// @todo: should the closing tag have a newline appended to it?
if (newLine) {
out.printil("out.write(\"--%>\");");
}
else {
out.println("--%>\");");
}
n.setEndJavaLine(out.getJavaLine());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org