Expand my Community achievements bar.

SOLVED

Applying Template to Custom Error Page

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 9

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

View solution in original post

5 Replies

Avatar

Correct answer by
Level 9

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

Avatar

Level 2

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?

Avatar

Level 9

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

Avatar

Level 2

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.

Avatar

Level 10

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