glassfish_at_javadesktop.org wrote:
>My apologies if this question's in the wrong area.
>
>Essentially what I'm trying to do, is test if a request that's received by a Filter is going to be a 404.
>
>I tried achieving this using the following code:
>
>[code]
>HttpServletRequest req = (HttpServletRequest)request;
>
>if (!new File(context.getRealPath(req.getRequestURI().substring(request.getContextPath().length()))).exists())
>{
> // 404'd
>}
>[/code]
>
>This works for [i]real[/i] files, but (obviously) doesn't pick up Servlet mappings. Is there either a generic function which takes a URI/URL and returns a (potential) error code, or some means I can use to determine the Servlet mappings, so I can test them myself?
>
>
Can you explain what the purpose of your filter is?
If its only purpose is to get at the response code, why not have
your filter wrap the response, where the response wrapper defines
a getter method for the response code?
Jan