Skip to main content
formis17
Level 2
Oct 16, 2015 2:26 AM UTC
Solved

Applying Template to Custom Error Page

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
MshajiAccepted solution
Community Advisor
Oct 16, 2015 2:26 AM UTC

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/)(.*)"))
    {
    ...
    }

5 replies

Sham_HC
Level 10
Oct 16, 2015 2:26 AM UTC

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.

 

https://forums.adobe.com/thread/1129498?tstart=0

Translate
formis17
formis17Author
Level 2
Oct 16, 2015 2:26 AM UTC

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.

Translate
Community Advisor
Oct 16, 2015 2:26 AM UTC

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

Translate
formis17
formis17Author
Level 2
Oct 16, 2015 2:26 AM UTC

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?

Translate
MshajiCommunity AdvisorAccepted solution
Community Advisor
Oct 16, 2015 2:26 AM UTC

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/)(.*)"))
    {
    ...
    }

Translate