Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#178 PageContext does not do Throwable

v3.0 Rabbit Hole
closed-invalid
Jason Dillon
7
2002-06-16
2002-03-19
Stephen Davidson
No

When compiling JSPs, the following is frequently added
to the generated Java file.
[javac] /tmp/Builds/HRneXus/war/jsp/Error.java:266:
handlePageException(java.lang.Exception) in
javax.servlet.jsp.PageContext cannot be applied to
(java.lang.Throwable)
[javac] if (pageContext != null)
pageContext.handlePageException(t);
[javac] ^

The Inteface defined by Sun is;
PageContext.handlePageException(java.lang.Exception e)

This causes the java compiler to fail when precompiling
JSPs.

The following is the recommended patch;

> cvs diff -u
src/main/org/apache/jasper/compiler/JspParseEventListener.java
Index:
src/main/org/apache/jasper/compiler/JspParseEventListener.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/apache/jasper/compiler/JspParseEventListener.java,v
retrieving revision 1.6
diff -u -r1.6 JspParseEventListener.java
---
src/main/org/apache/jasper/compiler/JspParseEventListener.java
11 Mar 2002 05:28:56 -0000 1.6
+++
src/main/org/apache/jasper/compiler/JspParseEventListener.java
19 Mar 2002 21:25:53 -0000
@@ -374,13 +374,21 @@

private void generateFooter() throws JasperException {
writer.popIndent();
- writer.println("} catch (Throwable t) {");
+ writer.println("} catch (RuntimeException e) {");
writer.pushIndent();
writer.println("if (out != null &&
out.getBufferSize() != 0)");
writer.pushIndent();
writer.println("out.clearBuffer();");
writer.popIndent();
- writer.println("if (pageContext != null)
pageContext.handlePageException(t);");
+ writer.println("if (pageContext != null)
pageContext.handlePageException(e);");
+ writer.popIndent();
+ writer.println("} catch (Exception e) {");
+ writer.pushIndent();
+ writer.println("if (out != null &&
out.getBufferSize() != 0)");
+ writer.pushIndent();
+ writer.println("out.clearBuffer();");
+ writer.popIndent();
+ writer.println("if (pageContext != null)
pageContext.handlePageException(e);");
writer.popIndent();
writer.println("} finally {");
writer.pushIndent();

Discussion

    • priority: 5 --> 7
     
  • Logged In: YES
    user_id=490856

    Reposting this patch.

     
  • Jason Dillon
    Jason Dillon
    2002-04-03

    Logged In: YES
    user_id=15045

    The Servlet API 2.3 specifies a
    PageContext.handlePageException(Throwable t), so applying
    this patch as is will make this non-compliant.

     
  • Jason Dillon
    Jason Dillon
    2002-04-03

    • status: open --> closed-invalid
     
  • Logged In: YES
    user_id=490856

    Please Note:
    pageContext.handlePageException(throwable) is not a valid
    J2EE API in the classes supplied by Sun. This causes code
    that can not be compiled to be generated. While it may be
    valid as defined in the spec, the classes supplied by Sun
    for JDK 1.3.1 do not support this. So we seem to be stuck
    with my patch.

    I have test cases if you would like to see.
    -Steve

     
    • status: closed-invalid --> open-invalid
     
  • Logged In: YES
    user_id=490856

    After checking at the Sun website,
    pageContext.handlePageException(throwable) is in fact
    defined there, so why this is throwing the above described
    exception, I have no idea, unless the class that was shipped
    was "defective".

    See original stackTrace where javac was complaining that it
    could not map "Throwable" to "Exception" at start of patch.

    -Steve

     
  • Jason Dillon
    Jason Dillon
    2002-04-06

    Logged In: YES
    user_id=15045

    What is the status of this? The given diff looks invalid
    per the spec. Please explain.

    --jason

     
  • Jason Dillon
    Jason Dillon
    2002-04-07

    Logged In: YES
    user_id=15045

    Please attach your test cases, so we can better the
    testsuite.

    --jason

     
  • Jason Dillon
    Jason Dillon
    2002-04-07

    • assigned_to: nobody --> user57
     
  • Logged In: YES
    user_id=490856

    Working for JDK 1.4 (Maybe just a Linux-JDK 1.3 issue?)

     
    • status: open-invalid --> closed-invalid