users@glassfish.java.net

isErrorPage="true" causes nullpointer exception in JSP

From: <glassfish_at_javadesktop.org>
Date: Wed, 26 Aug 2009 20:25:27 PDT

Hi All,
Firstly, apologies for this not being solely an appserver problem. It crosses several domains (JSP, appserver, tiles, struts version 1.2.9) and hence it's tricky to pin down. Also note, this is for Sun Application Server 9

I have a login page that the user accesses. When they submit, the struts action handling executes some user code which throws an exception (as expected). Struts hands over to the error page as a result of the struts <global-exceptions/>. This part seems to work ok. In the struts xml the name of a tile is listed. If I forward to a tile that loads my error page directly, everything works fine, e.g.

<definition name="error" path="/WEB-INF/pages/content/inc_error.jsp">



Note: In this scenario, even though the error page doesn't reference the template, the header and footer mentioned in the template are still displayed in the browser. From what I can gather, this may be because they're rendered in the browser before any error is thrown, and therefore the exception page is shown with them, but this seems a little strange (related?) to me.

If I forward to a tile that loads the template and then inserts the error page, I get a null pointer exception.

<definition name="error" extends="template">
        <put name="body" value="/WEB-INF/pages/content/inc_error.jsp"/>
</definition>




This is the line of code in the error handling jsp that causes the problem.

<%@ page isErrorPage="true" %>



Which once compiled generates the following code on Sun Application Server PE 9 which throws the nullpointerexception

response.setStatus(((Integer)request.getAttribute("javax.servlet.error.status_code")).intValue());




Does anyone have any ideas for what might be going wrong?
[Message sent by forum member 'mj3' (michael.jordan_at_unico.com.au)]

http://forums.java.net/jive/thread.jspa?messageID=362086