Hi,
We recently set up a custom error page by overlaying /libs/sling/servlet/errorhandler/404.jsp.
our 404.html contains:
<html data-sly-use.responseStatus="apps.sling.servlet.errorhandler.ResponseStatus404">
...
</html>
and the ResponseStatus404.java file contains this:
public void activate() throws Exception {
getResponse().setStatus(404);
}
The error page works fine for URLs with a .html extension (/abc/pqr.html)
But if there is no extension or some other extension like .txt, then it displays the full code of our custom error page but doesn't render the page. I checked in /system/console/requests and saw that our custom error page is indeed being called, but for some reason it doesn't get rendered and instead we see the html code of the error page.
Please let me know how I should fix this issue and make the error page work for all extensions/no extension in URL.
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @abinav_98 ,
You should specify the content type in ResponseStatus404.java as well:
public void activate() throws Exception {
getResponse().setStatus(404);
getResponse().setContentType("text/html");
}
Regards
Hello @abinav_98 ,
You should specify the content type in ResponseStatus404.java as well:
public void activate() throws Exception {
getResponse().setStatus(404);
getResponse().setContentType("text/html");
}
Regards
Views
Replies
Total Likes
Views
Likes
Replies