Thursday, 5 September 2013

Uniform http error pages

Uniform http error pages

I would like to make all my http error pages uniform so that they are
displayed using my websites theme. Out of the box liferay seem to be
handling some errors and ignoring others, leaving it up to tomcat to
display them in its well known format. Now 404 is for example handled by
liferay. It is displayed by status.jsp and has the same theme as the rest
of my site. status.jsp seems only to support a few error messages like 404
and 500. My idea to solve this is to add more error codes in
ROOT/WEB-INF/web.xml like 401,403,405 and so on. I can point all these to
a jsp ROOT/errors/error.jsp that does something like
<body
onload="javascript:location.replace('http://localhost:8080/c/portal/status?err=<%=
pageContext.getErrorData().getStatusCode() %>&uri=<%=
pageContext.getErrorData().getRequestURI() %>')">
This way I get some necessary data into status.jsp. And can display a
message that contains both the http code and the URI that caused it using
a hook that overrides the original status.jsp.
Now, is this a reasonable way of achieving the uniform status pages? Is
there a better way?

No comments:

Post a Comment