Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Error handling for all extensions

Avatar

Level 1

Hi!

I added custom error scripts in /apps/sling/servlet/errorhandler/ (403.jsp, 404.jsp, default.jsp and Throwable.jsp).

If I try to display an unexisting page on my AEM 5.6.1 instance with .html extension, for example http://localhost:4502/content/mysite/mypath/unexistingpage.html), my personalized 404 page is displayed.

But if I try to display this same page without the extension (http://localhost:4502/content/mysite/mypath/unexistingpage), the browser's error page is displayed, same if I put .htm extension.

Any idea how to handle all these error cases?

Thanks for help !

1 Accepted Solution

Avatar

Correct answer by
Level 2

visitashi wrote...

Blaise Grand wrote...

Yes I customized the error handling with this method but it works only for pages with .html extension. I think another default handler is called for unsupported extensions (or no extension too, in my case). And returns q 404 status code. I want to override this with my custom handler but how can I do this? I tried to override the original CQ 404.jsp and other error handling files, but no change.

 

Hi All,

We are also facing a similar issue wherein at the same level for some pages our custom error message shows and for some other pages it shows forbidden or not found .

eg: we access the url type as http://www.abc.com/a/b/c/ ----- this gives forbidden and the url  http://www.abc.com/a/b/d/ --- gives the custom error page for 403 which we have created.

we had similar setting for one of the other sites where the custom error handler works fine but here it doesnt.

we tried to check the dipatcher settings . they seem similar to the site where it works pretty fine. so, we cant seem to understand the reason behind this.

pls help if anyone has faced any similar issues.

 

Thanks and Regards

Ashish

 

 

Hi Everyone, 

I got the solution to this .

I used url shortening through etc/map.publish  and it works fine for me now.

View solution in original post

6 Replies

Avatar

Level 8

Have you looked in your error.log to see if anything is being logged when the system receives the request without the extension? It is possible that you are actually generating an error in your custom JSPs which would explain why the browser error page is being displayed. 

The other thing to do is look is look at the recent request page in the Felix console after you receive a request without and extension and check the stacktrace there. That will tell you which handlers are being called. 

Avatar

Level 1
        Yes I customized the error handling with this method  but it works only for pages with .html extension. I think another default handler is called for unsupported extensions (or no extension too, in my case). And returns q 404 status code. I want to override this with my custom handler but how can I do this? I tried to override the original CQ 404.jsp and other error handling files, but no change.

Avatar

Level 2

Blaise Grand wrote...

Yes I customized the error handling with this method but it works only for pages with .html extension. I think another default handler is called for unsupported extensions (or no extension too, in my case). And returns q 404 status code. I want to override this with my custom handler but how can I do this? I tried to override the original CQ 404.jsp and other error handling files, but no change.

 

Hi All,

We are also facing a similar issue wherein at the same level for some pages our custom error message shows and for some other pages it shows forbidden or not found .

eg: we access the url type as http://www.abc.com/a/b/c/ ----- this gives forbidden and the url  http://www.abc.com/a/b/d/ --- gives the custom error page for 403 which we have created.

we had similar setting for one of the other sites where the custom error handler works fine but here it doesnt.

we tried to check the dipatcher settings . they seem similar to the site where it works pretty fine. so, we cant seem to understand the reason behind this.

pls help if anyone has faced any similar issues.

 

Thanks and Regards

Ashish

Avatar

Correct answer by
Level 2

visitashi wrote...

Blaise Grand wrote...

Yes I customized the error handling with this method but it works only for pages with .html extension. I think another default handler is called for unsupported extensions (or no extension too, in my case). And returns q 404 status code. I want to override this with my custom handler but how can I do this? I tried to override the original CQ 404.jsp and other error handling files, but no change.

 

Hi All,

We are also facing a similar issue wherein at the same level for some pages our custom error message shows and for some other pages it shows forbidden or not found .

eg: we access the url type as http://www.abc.com/a/b/c/ ----- this gives forbidden and the url  http://www.abc.com/a/b/d/ --- gives the custom error page for 403 which we have created.

we had similar setting for one of the other sites where the custom error handler works fine but here it doesnt.

we tried to check the dipatcher settings . they seem similar to the site where it works pretty fine. so, we cant seem to understand the reason behind this.

pls help if anyone has faced any similar issues.

 

Thanks and Regards

Ashish

 

 

Hi Everyone, 

I got the solution to this .

I used url shortening through etc/map.publish  and it works fine for me now.

Avatar

Level 1

Hi Vistashi

 

Can you please share the URL shortening code that worked for you?