Thursday, March 15, 2007

Can't get or find errorData attribute in JSP pageContext

Keywords:
error JSP pageContext errorData scriplet

Problem:
Writing a JSP that handles errors from JSP, servlets (and other!) need to access the ErrorData object in a scriptlet rather that the convenient JSP EL ${pageContext.errorData}.

Tried:
pageContext.getAttribute("errorData"); but this returns null. Maybe it's not in the page scope.
pageContext.findAttribute("errorData"); but still null.

Solution:
Thankfully there's the convenience method:
pageContext.getErrorData();

This works. It seems the JSP EL ${pageContext.errorData} is a way of referencing this accessor rather than an element in the pageContext "map".

No comments: