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=6552>. 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=6552 comments parsed in jsp pages Summary: comments parsed in jsp pages Product: Tomcat 4 Version: 4.0.2 Final Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Inside <%! %> tags if you have // comments and inside has <%= %> tags which often happens when debugging codes or commenting old lines out, the jsp parser STILL parses that but incorrectly and would render the page into errors. For example, I have the following test.jsp page. Note the lines after if (localSection != null) { how it actually parsed the comments too and left out the rest of the important codes! ----------------------------------beginning of file--------------------------- <% /** * index.jsp * Author: Harlow * * Description: * This is the kids template page. * * Updates: * 12/7/2000 - Moon - Code Review * 4/10/2001 - Harlow - Added keyword to quick search */ %> <%@page import="java.text.*"%> <%@page import="java.util.Vector"%> <%@page import="java.util.Enumeration"%> <%@page import="com.ixl.booksense.stores.*"%> <%@page import="com.ixl.geography.*"%> <%@page import="com.ixl.booksense.context.*"%> <%@page import="com.ixl.booksense.books.*"%> <%@page import="com.ixl.booksense.nationalData.*"%> <%@page import="com.ixl.booksense.siteModel.specialized.*"%> <%@page import="com.ixl.booksense.siteModel.generic.*"%> <%! /** getLeftNavSectionString returns proper formatting for left nav sections TODO: Optimize construction of the returnString... this function is called seven times for each page. */ private String getLeftNavSectionString(String sectionName, StandardColorScheme scheme, Site site, String storeIndexPath, boolean isSecure) { String returnString = ""; try { NoBodyLocalSection localSection = (NoBodyLocalSection) site.getSection(sectionName); if (localSection != null) { // returnString = "<a href=\"http://<%= storeIndexPath %>? s=" + sectionName + "\"><font color=\"" + scheme.getLEFTNAV_LINK() + "\">"; // returnString = returnString + localSection.getTitle() + "</font></a><br>"; // returnString = returnString + "<img src=\"" + scheme.getFULL_IMAGE_URL(isSecure) + "clear.gif\" width=\"1\" height=\"12 \"><br>"; returnString = "<tr>"; } } catch (Exception e) { returnString = ""; } return returnString; } %> <jsp:useBean id="storeBean" scope="request" class="com.ixl.booksense.beans.stores.StoreBean" /> <html> <head> <title><%= storeTitle %></title> </head> <body bgcolor="#FFFFFF" link="#000000" vlink="#000000" alink="#000000" background="<%= scheme.getFULL_IMAGE_URL(isSecure) %>04_background.gif"> </body> </html> -----------------------------------end of file--------------------------- and it gets parsed into ---------------------------------beginning of file--------------------------- package org.apache.jsp; import java.text.*; import java.util.Vector; import java.util.Enumeration; import com.ixl.booksense.stores.*; import com.ixl.geography.*; import com.ixl.booksense.context.*; import com.ixl.booksense.books.*; import com.ixl.booksense.nationalData.*; import com.ixl.booksense.siteModel.specialized.*; import com.ixl.booksense.siteModel.generic.*; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import org.apache.jasper.runtime.*; public class test$jsp extends HttpJspBase { // begin [file="/test.jsp";from=(25,3);to=(40,62)] /** getLeftNavSectionString returns proper formatting for left nav sections TODO: Optimize construction of the returnString... this function is called seven times for each page. */ private String getLeftNavSectionString(String sectionName, StandardColorScheme scheme, Site site, String storeIndexPath, boolean isSecure) { String returnString = ""; try { NoBodyLocalSection localSection = (NoBodyLocalSection) site.getSection(sectionName); if (localSection != null) { // returnString = "<a href=\"http://<%= storeIndexPath // end // begin [file="/test.jsp";from=(55,0);to=(55,95)] // end static { } public test$jsp( ) { } private static boolean _jspx_inited = false; public final void _jspx_init() throws org.apache.jasper.runtime.JspException { } 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; String _value = null; try { if (_jspx_inited == false) { synchronized (this) { if (_jspx_inited == false) { _jspx_init(); _jspx_inited = true; } } } _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=ISO-8859-1"); pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); // begin [file="/test.jsp";from=(0,2);to=(12,0)] /** * index.jsp * Author: Harlow * * Description: * This is the kids template page. * * Updates: * 12/7/2000 - Moon - Code Review * 4/10/2001 - Harlow - Added keyword to quick search */ // end // HTML // begin [file="/test.jsp";from=(12,2);to=(15,0)] out.write("\r\n\r\n\r\n"); // end // HTML // begin [file="/test.jsp";from=(15,30);to=(16,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(16,35);to=(17,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(17,40);to=(18,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(18,45);to=(19,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(19,38);to=(20,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(20,46);to=(21,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(21,44);to=(22,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(22,51);to=(23,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(23,60);to=(24,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(24,56);to=(25,0)] out.write("\r\n"); // end // HTML // begin [file="/test.jsp";from=(40,64);to=(55,0)] out.write("?s=\" + sectionName + \"\\\"><font color=\\\"\" + scheme.getLEFTNAV_LINK() + \"\\\">\";\r\n\t\t // returnString = returnString + localSection.getTitle() + \"</font></a><br>\";\r\n\t\t // returnString = returnString + \"<img src=\\\"\" + scheme.getFULL_IMAGE_URL (isSecure) + \"clear.gif\\\" width=\\\"1\\\" height=\\\"12\\\"><br>\";\r\n\r\n \t\t\t returnString = \"<tr>\";\r\n\t\t }\r\n } catch (Exception e) {\r\n returnString = \"\";\r\n }\r\n\r\n return returnString;\r\n }\r\n\r\n%>\r\n\r\n"); // end // begin [file="/test.jsp";from=(55,0);to=(55,95)] com.ixl.booksense.beans.stores.StoreBean storeBean = null; boolean _jspx_specialstoreBean = false; synchronized (request) { storeBean= (com.ixl.booksense.beans.stores.StoreBean) pageContext.getAttribute ("storeBean",PageContext.REQUEST_SCOPE); if ( storeBean == null ) { _jspx_specialstoreBean = true; try { storeBean = (com.ixl.booksense.beans.stores.StoreBean) java.beans.Beans.instantiate (this.getClass().getClassLoader(), "com.ixl.booksense.beans.stores.StoreBean"); } catch (ClassNotFoundException exc) { throw new InstantiationException(exc.getMessage()); } catch (Exception exc) { throw new ServletException (" Cannot create bean of class "+"com.ixl.booksense.beans.stores.StoreBean", exc); } pageContext.setAttribute("storeBean", storeBean, PageContext.REQUEST_SCOPE); } } if(_jspx_specialstoreBean == true) { // end // begin [file="/test.jsp";from=(55,0);to=(55,95)] } // end // HTML // begin [file="/test.jsp";from=(55,95);to=(59,10)] out.write("\r\n\r\n<html>\r\n<head>\r\n <title>"); // end // begin [file="/test.jsp";from=(59,13);to=(59,25)] out.print( storeTitle ); // end // HTML // begin [file="/test.jsp";from=(59,27);to=(61,83)] out.write("</title>\r\n</head>\r\n<body bgcolor=\"#FFFFFF\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\" background=\""); // end // begin [file="/test.jsp";from=(61,86);to=(61,122)] out.print( scheme.getFULL_IMAGE_URL(isSecure) ); // end // HTML // begin [file="/test.jsp";from=(61,124);to=(65,0)] out.write("04_background.gif\">\r\n\r\n</body>\r\n</html>\r\n"); // end } catch (Throwable t) { if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext (pageContext); } } } -----------------------------------end of file--------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>