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/06/20 13:52:09 UTC

DO NOT REPLY [Bug 20948] New: - Jasper error in JSP source to Java servlet code generation

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

Jasper error  in JSP source to Java servlet code generation

           Summary: Jasper error  in JSP source to Java servlet code
                    generation
           Product: Tomcat 4
           Version: 4.1.12
          Platform: PC
        OS/Version: Windows 9x
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: JBStonehenge@aol.com


Hi folks,

I revealed a smart bug in the parsing strategy of JSP. I'm using
Tomcat 4.1.12 on Windows ME environment.
There is a problem when using a Java comment "//" followed by "%>",
the end token of Java embedded JSP.

	<%
	if (...)
	{
		...
	} // endif %>
	</TABLE></FORM></BODY></HTML>

This would result in the JSP' servlet code:

	} // endif      out.write("\n\t</TABLE></FORM></BODY></HTML>");

The servlet execution result is, that the complete out.write() is not executed.
Thus, all the HTML tags are missing.
The Java line comment has to be overruled by the JSP end token
so that the Java line comment ends there!
Otherwise everything which is combined together in the following out.write()
statement remains comment (so substantial Java code is likely to disappear).


More detailed Example:
JSP (it is indeed dynamic JavaScript):

   function FieldPageBack()
   {
      FieldOffset = FieldOffset - 1;
      <%= (AdmList.getPageType() == AdmList.c_ListDelEntry)?
         "setAttrClassReadOnlyValues(FieldOffset);" : "setAttrClassSelectIndex
(FieldOffset);" %>
   <% for (int i = 0; i < AdmList.c_FieldsToDisplay; i++) { %>
         FieldNo[<%= i %>].innerHTML = (FieldOffset + <%= i %>) + ".";
   <% } // endfor %>
   }
   function FieldPageForward()
   {
      FieldOffset = FieldOffset + 1;
      <%= (AdmList.getPageType() == AdmList.c_ListDelEntry)?
         "setAttrClassReadOnlyValues(FieldOffset);" : "setAttrClassSelectIndex
(FieldOffset);" %>
   <% for (int i = 0; i < AdmList.c_FieldsToDisplay; i++) { %>
         FieldNo[<%= i %>].innerHTML = (FieldOffset + <%= i %>) + ".";
   <% } // endfor %>
   }

JSP-generated Servlet:

      out.write("\nfunction FieldPageBack()\n{\n\tFieldOffset = FieldOffset - 
1;\n\t");
      out.print( (AdmList.getPageType() == AdmList.c_ListDelEntry)?
		"setAttrClassReadOnlyValues
(FieldOffset);" : "setAttrClassSelectIndex(FieldOffset);" );
      out.write("\n");
 for (int i = 0; i < AdmList.c_FieldsToDisplay; i++) {       out.write
("\n\tFieldNo[");
      out.print( i );
      out.write("].innerHTML = (FieldOffset + ");
      out.print( i );
      out.write(") + \".\";\n");
 } // endfor       out.write("\n}\nfunction FieldPageForward()\n
{\n\tFieldOffset = FieldOffset - 1;\n\t");
      out.print( (AdmList.getPageType() == AdmList.c_ListDelEntry)?
		"setAttrClassReadOnlyValues
(FieldOffset);" : "setAttrClassSelectIndex(FieldOffset);" );
      out.write("\n");
 for (int i = 0; i < AdmList.c_FieldsToDisplay; i++) {       out.write
("\n\tFieldNo[");
      out.print( i );
      out.write("].innerHTML = (FieldOffset + ");
      out.print( i );
      out.write(") + \".\";\n");
 } // endfor       out.write("\n}\n");


Best regards,
Johannes

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