tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bucknam, Brian" <>
Subject Jasper Compiler -- when things go really wrong
Date Tue, 19 Dec 2000 19:34:39 GMT
It's a long story, but I'm working on a project where Jasper 3.x is embedded
inside a servlet, which can then be deployed to the container of our
customer's choice.  The servlet uses JSP files as templates, which is where
Jasper comes in.

In this type of environment, sometimes thing can go really wrong, and the
compiled JSP might, in some cases, fail to get a JspFactory, PageContext, or

Here is a much-snipped version of what JspParseEventListener (in 3.2 and
4.0) generates for the _jspService() method:
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
JspWriter out = null;
try {
    _jspxFactory = JspFactory.getDefaultFactory();
    pageContext = _jspxFactory.getPageContext(this, request, response,
          "", true, 4096, true);

    out = pageContext.getOut();

    // HTML stuff here
        out.write(" happy JSP page...");
    // end
} catch (Exception ex) {
    if (out.getBufferSize() != 0)
} finally {

If any of _jspxFactory, pageContext, or out fail to be created, the catch{}
and finally{} clauses just throw NPE's.

I would propose that the catch{} and finally{} should generated as following
} catch (Exception ex) {
    if (out != null && out.getBufferSize() != 0)
    if (pageContext != null) pageContext.handlePageException(ex);
} finally {
    if (out != null) out.flush();
    if (_jspxFactory != null)

These seem to me like non-functionality-impacting changes.

If this seems right, I will generate patch files if requested.


Brian Bucknam
WebGain, Inc.

View raw message