View Single Post
  #1  
Old 03-17-2011, 07:24 AM
imaniyar imaniyar is offline
Junior Member
 
Join Date: Mar 2011
Posts: 1
Default Resin doesn't compile JSP properly while Tomcat does

I thought the following code was portable. However, Tomcat 6.0.20 does it right, while Caucho Resin Pro 4.0.15 seems to be compiling it wrong.

My JSP code is as follows:

Code:
<jsp:scriptlet>  
    String referrer = request.getHeader("referer");  
    if( referrer != null ){  
</jsp:scriptlet>  
  
    <p>  
        You may   
        <jsp:element name="a">  
            <jsp:attribute name="href">  
                <jsp:expression>response.encodeURL(referrer)</jsp:expression>  
            </jsp:attribute>  
            <jsp:body>click here</jsp:body>  
        </jsp:element>   
        to return to the page you came from.  
    </p>  
      
<jsp:scriptlet>  
    }  
</jsp:scriptlet>
Tomcat compiles it to the following in the class org.apache.jsp.WEB_002dINF.error_002dpages._404_js p:
_jspService

Code:
.  
.  
.  
String referrer = request.getHeader("referer");  
if( referrer != null ){  
                      
      out.write("\r\n");  
      out.write("\t\t\t\t\t\r\n");  
      out.write("\t\t\t\t\t\t<p>\r\n");  
      out.write("\t\t\t\t\t\t\tYou may \r\n");  
      out.write("\t\t\t\t\t\t\t");  
      out = _jspx_page_context.pushBody();  
      out.print(response.encodeURL(referrer));  
      String _jspx_temp2 = ((javax.servlet.jsp.tagext.BodyContent)out).getString();  
      out = _jspx_page_context.popBody();  
      out.write("<" + "a" + " href=\"" + _jspx_temp2 + "\"" + ">");  
      out.write("click here");  
      out.write("</" + "a" + ">");  
      out.write(" \r\n");  
      out.write("\t\t\t\t\t\t\tto return to the page you came from.\r\n");  
      out.write("\t\t\t\t\t\t</p>\r\n");  
      out.write("\t\t\t\t\t\t\r\n");  
      out.write("\t\t\t\t\t");  
  
}  
.  
.  
.
Resin compiles it to the following in the class _jsp._web_22dinf._error_22dpages._404_jsp:
_jspService
Code:
.  
.  
.  
String referrer = request.getHeader("referer");  
if( referrer != null ){  
                      
    out.write(_jsp_string51, 0, _jsp_string51.length);  
    out.print(_jsp_fragment_4(pageContext, null, null, _jsp_state, _jsp_pageManager));out.write(_jsp_string52, 0, _jsp_string52.length);  
      
}  
.  
.  
.
In String _jsp_fragment_4(

Code:
 String _jsp_fragment_4(  
    com.caucho.jsp.PageContextImpl pageContext,  
    javax.servlet.jsp.tagext.JspTag _jsp_parent_tag,  
    javax.servlet.jsp.tagext.JspFragment _jspBody,  
    TagState _jsp_state,  
    com.caucho.jsp.PageManager _jsp_pageManager)  
    throws Throwable  
  {  
    com.caucho.jsp.PageContextImpl _jsp_parentContext = pageContext;  
    JspWriter out = pageContext.pushBody();  
    javax.el.ELContext _jsp_env = pageContext.getELContext();  
    javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) pageContext.getRequest();  
    javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse) pageContext.getResponse();  
    javax.servlet.http.HttpSession session = pageContext.getSession();  
    javax.servlet.ServletContext application = pageContext.getServletContext();  
    javax.servlet.ServletConfig config = pageContext.getServletConfig();  
    try {  
      out.print((response.encodeURL(referrer)));  
      return ((com.caucho.jsp.BodyContentImpl) out).getString();  
    } finally {  
      pageContext.popAndReleaseBody();  
    }  
  }
Due to the function _jsp_fragment_4 that the Coucho Resin jsp compiler produces, Coucho Resin ends up through a INTERNAL SERVER ERROR because it cannot compile the jsp file into a servlet.

Do you think Caucho Resin is at fault?
Reply With Quote