2

In my web.xml, I have

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/WEB-INF/errorpages/expired.xhtml</location>
</error-page>

But if a ViewExpiredException is thrown (Non - AJAX), it ends up in a 404 - Not Found basic page with an url /WEB-INF/errorpages/expired.xhtml. If I change the location to /expired.xhtml (and copy the file expired.xhtml under webapp directory) it works fine and the url is /expired.xhtml after the ViewExpiredException is thrown.

Well, the file expired.xhtml should be in WEB-INF directory. Why is it not working with the WEB-INF path ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
grigouille
  • 511
  • 3
  • 14

2 Answers2

0

It turned out you are using the PrimeFaces PrimeExceptionHandler. This handler will redirect you to the error location, which will fail if the location is within the WEB-INF folder. To fix this you can use no specific handler or use one that does not redirect.

I personally use a customized version of the OmniFaces FullAjaxExceptionHandler (which does support locations within the WEB-INF folder).

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • The OmniFaces FullAjaxExceptionHandler does the job. I got then a css problem. This post can fix it : https://stackoverflow.com/q/43224613/14946729 – grigouille Jun 13 '22 at 08:37
  • It might be possible to overcome this limitation via another ExceptionHandler but its not a good pattern to put views inside WEB-INF, see my answer – tandraschko Jun 13 '22 at 09:20
  • The error pages in omnifaces are in WEB-INF. You don't want those pages bookmarkable. – grigouille Jun 13 '22 at 10:47
0

Files inside WEB-INF are not serveable via browser without forward/rewrite

So just dont put views in WEB-INF, thats not a good pattern

tandraschko
  • 2,291
  • 13
  • 13