Question

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 formattomcat 403. 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?

Was it helpful?

Solution

You can define error pages in your web.xml. refer to distinct controllers which wil delegated to JSPs with prepared data. Never ever use scriptlets in JSPs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top