Applying Template to Custom Error Page | Community
Skip to main content
formis17
Level 2
October 16, 2015
Solved

Applying Template to Custom Error Page

  • October 16, 2015
  • 5 replies
  • 1338 views

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.
Best answer by Mshaji

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

MshajiCommunity AdvisorAccepted solution
Community Advisor
October 16, 2015

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

formis17
formis17Author
Level 2
October 16, 2015

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?

Community Advisor
October 16, 2015

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

formis17
formis17Author
Level 2
October 16, 2015

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.

Sham_HC
Level 10
October 16, 2015

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