Hello,
I am attempting to create a custom error page for my company's website. I followed the instructions found in http://docs.adobe.com/docs/en/cq/current/developing/customizing_error_handler_pages.html. Although my error page does appear as expected, it does not mimic the appearance of the rest of the site. Is there a way to apply my site's template to the custom error page?
Thanks,
Sarah
Solved! Go to Solution.
Views
Replies
Total Likes
Yes, you create a template and corresponding page component. Once you have this create a page with this template, you can hide in navigation so as not to be picked up by navigation component.
Your page will be having a path like /content/yourapp/en/404.html
In your /apps/sling/servlet/errorhandler/404.jsp
You can have code like this to redirect to your custom page
String uri = request.getRequestURI();
if(uri.matches("(/content/yourapp/en/)(.*)"))
{
pageContext.include("/content/yourapp/en/404.html");
} else if(uri.matches("(/content/yourapp/es/)(.*)"))
{
...
}
Views
Replies
Total Likes
Yes, you create a template and corresponding page component. Once you have this create a page with this template, you can hide in navigation so as not to be picked up by navigation component.
Your page will be having a path like /content/yourapp/en/404.html
In your /apps/sling/servlet/errorhandler/404.jsp
You can have code like this to redirect to your custom page
String uri = request.getRequestURI();
if(uri.matches("(/content/yourapp/en/)(.*)"))
{
pageContext.include("/content/yourapp/en/404.html");
} else if(uri.matches("(/content/yourapp/es/)(.*)"))
{
...
}
Views
Replies
Total Likes
Thanks! That worked perfectly! Unfortunately, when I include the page in my 404.jsp script, the page is missing all of the i18n files. The labels are all messed up. How can I include the i18n files through the 404.jsp file?
Views
Replies
Total Likes
I am not sure how you are doing translations, do you have absolute path for the files you are including in the jsp file.
Please check the template and corresponding jsp by directly invoking instead of through 404.jsp
Views
Replies
Total Likes
I'm sorry for the delayed reply! When I invoke the template directly (through site admin) the i18n labels appear as expected. However, when I access the page through the 404.jsp file (by typing the url incorrectly) the labels are missing.
Views
Replies
Total Likes
formis17 wrote...
I'm sorry for the delayed reply! When I invoke the template directly (through site admin) the i18n labels appear as expected. However, when I access the page through the 404.jsp file (by typing the url incorrectly) the labels are missing.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies