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 2003/12/06 23:44:17 UTC

DO NOT REPLY [Bug 25263] New: - Incorrect SMAP generated for JSP

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=25263>.
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=25263

Incorrect SMAP generated for JSP

           Summary: Incorrect SMAP generated for JSP
           Product: Tomcat 5
           Version: 5.0.16
          Platform: Other
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: todd@genuitec.com


Below is an example SMAP, JSP, and generated Java file that demonstrate an 
error in the SMAP generation.

The test JSP (with line numbers) looks like this:

01  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
02  <%@ page language="java" import="java.lang.*,java.util.*" %>
03  <%
04  String path = request.getContextPath();
05  String basePath = "http://"+request.getServerName()
06  +":"+request.getServerPort()+path+"/";
07  %>
08  <HTML>
09    <HEAD>
10      <BASE HREF="<%=basePath%>">     
11      <TITLE>My JSP 'TestJSP.jsp' starting page</TITLE>
12    </HEAD>
13
14      <BODY>
15        <% 
16          Date date = new Date(); 
17          out.println("Current time is: " + date);
18          out.println(".  ");
19          date = new Date(); 
20          out.println("Now the time is " + date);
21          out.println(".  ");
22        %>
23        <BR>This is my test JSP page. <BR>
24      </BODY>
25  </HTML>

The SMAP generated is as follows:

SMAP
TomcatTestJSP_jsp.java
JSP
*S JSP
*F
+ 0 TomcatTestJSP.jsp
TomcatTestJSP.jsp
*L
1,3:42
4,3:44
6,4:47
9:48,2
10,5:50
15,7:51
21,5:58
*E

The mapping of 10,5:50 is erroneous. It is both the wrong area within the 
generated java file, and it overlaps with the subsequent correct mapping of the 
embedded java scriptlet at 15,7:51.

Here's the generated java file to which I added line number comments for 
illustration:

package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.lang.*;
import java.util.*;

public final class TomcatTestJSP_jsp extends 
org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse 
response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 
Transitional//EN\">\r\n\r\n"); // line number 42

String path = request.getContextPath(); // line 44
String basePath = "http://"+request.getServerName()+":"+request.getServerPort()
+path+"/"; // line 45

      out.write("\r\n<HTML>\r\n\t<HEAD>\r\n\t\t<BASE HREF=\""); //line 47
      out.print(basePath); // line 48
      out.write("\">\t\t\r\n\t\t<TITLE>My JSP 'TestJSP.jsp' starting 
page</TITLE>\r\n\t</HEAD>\r\n\r\n\t<BODY>\r\n\t  "); // line 49
 
	  	Date date = new Date(); // line 51
	  	out.println("Current time is: " + date); // line 52
      out.println(".  "); // line 53
      date = new Date();  // line 54
      out.println("Now the time is " + date); // line 55
      out.println(".  "); // line 56
	  
      out.write("\r\n\t\t<BR>This is my test JSP page. 
<BR>\r\n\t</BODY>\r\n</HTML>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (pageContext != null) pageContext.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
}

>From this code, the lines 10-14 in the JSP should be mapped only to line 49 
(like 10,5:49,0), but not to 50-54 as the 10,5:50 mapping dictates.  This is 
certainly not the only time we've seen problems with this latest release, but 
this is one of the smallest test cases we could produce.

For the record, the mappings in the previous version we tested, 5.0.12 were 
correct and are reproduced below. 

SMAP
TomcatTestJSP_jsp.java
JSP
*S JSP
*F
+ 0 /TomcatTestJSP.jsp
TomcatTestJSP.jsp
*L
1,2:42
4,3:45
6,2:48
8:49,2
9:50,4
10:53,3
11:55,2
12:56
13:56,2
14:57
15,7:59
21:66
22:66,3
23:68,2
24:70
*E

Although the output lines are different, due to changes in the JSP to Java 
translation, you'll note that the lines prior to line 15 are properly generated 
to previous lines in the java file in a non-overlapping manner with the 15,7:59 
mapping, which is where the next java block begins.  This problem with the SMAP 
currently prevents IDE's from properly supporting source-level JSP debugging.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org