myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Reznick <vedm...@gmail.com>
Subject Re: Custom <error-page> is being ignored (only for certain paths)
Date Sun, 14 Jul 2013 08:32:26 GMT
Hi

Is there any better way to resolve that rather than writing my own filter
with overkill code?

Regards,

Daniel.


On Sun, Jul 7, 2013 at 2:28 PM, Daniel Reznick <vedmack@gmail.com> wrote:

> For some reason my
>
>     <error-page>
>         <error-code>404</error-code>
>         <location>/error/error.html</location>
>     </error-page>
>
> which is defined in tomcat\conf\web.xml is being ignored when I'm trying
> to access the following path
>
> WebAppName/javax.faces.resource/anyFileName.jsf
>
> I know that its cause of the *javax.faces.resource* prefix and the *.jsf*
> suffix combined together...
>
> cause if I change one of them I do get the custom error page
>
> I do know that its not a common path to pick, but still I wonder how can I
> make it use my custom error-page
>
> b.t.w , I'm using *myfaces 2.0.11*
>
> I found one way to overcome it by using implementing custom filter and
> setting response.sendError(404.... but Its not a good solution IMO , cause
> I need to use "new File" each time to check for existence and add some
> logic for converting the .jsf to xhtml or omitting .jsf before checking the
> ".exists()" for the file
>
> this is a code snippet:
>
> String path = ((HttpServletRequest) req).getServletPath();
> if (((HttpServletRequest)
> req).getRequestURI().contains("javax.faces.resource")
>  && !new
> File(getFilterConfig().getServletContext().getRealPath(path)).exists()) {
>  HttpServletResponse response = (HttpServletResponse) res;
>  response.sendError(404, "Cannot find " + path);
> } else {
> chain.doFilter(req, res);
> }
>
> Is there any other better way to use the Custom <error-page> for path of
> the type "WebAppName/javax.faces.resource/anyFileName.jsf"
>
>
> Regards,
>
> Daniel.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message