Re: Throwing exception when including unexisting resource

2008-10-22 Thread Antonio
2008/10/22 Tim Funk <[EMAIL PROTECTED]>: > This would not work for includes since includes can't change the status or > change any headers. I think that I will try the "404 + 0 bytes" approach then. Thanks Antonio - To start a n

Re: Throwing exception when including unexisting resource

2008-10-22 Thread Tim Funk
This would not work for includes since includes can't change the status or change any headers. -Tim Filip Hanik - Dev Lists wrote: you could also create a response wrapper in a filter, capture the status/output, so if the servlet sets 404, you can react to it appropriately Filip Antonio wrot

Re: Throwing exception when including unexisting resource

2008-10-22 Thread Tim Funk
getServletPath() should return the path of the requested resource. So if I call include("/foo.html") - getServletPath() at that point during invocation should be /foo.html. servletContext.getResource(stuff) returns a URL if the resource exists. For servlets which map to some extension like *.d

Re: Throwing exception when including unexisting resource

2008-10-22 Thread Antonio
2008/10/22 Filip Hanik - Dev Lists <[EMAIL PROTECTED]>: > you could also create a response wrapper in a filter, capture the > status/output, > so if the servlet sets 404, you can react to it appropriately You're right, thanks :-) Antonio --

Re: Throwing exception when including unexisting resource

2008-10-22 Thread Filip Hanik - Dev Lists
you could also create a response wrapper in a filter, capture the status/output, so if the servlet sets 404, you can react to it appropriately Filip Antonio wrote: 2008/10/22 Tim Funk <[EMAIL PROTECTED]>: if (null==servletContext.getResource(request.getServletPath())) { Are you sure

Re: Throwing exception when including unexisting resource

2008-10-22 Thread Antonio
2008/10/22 Tim Funk <[EMAIL PROTECTED]>: > if (null==servletContext.getResource(request.getServletPath())) { Are you sure that it works? the "getServletPath" returns the path or the name of the servlet. Notice that anything could be included, from a JSP page to a called servlet with parameters. A

Re: Throwing exception when including unexisting resource

2008-10-22 Thread Tim Funk
This can be done in a Filter. Horribly pseudo coded as: doFilter(...) { if (null==servletContext.getResource(request.getServletPath())) { throw new ServletException("No file"); } chain.doFilter(...); } Then map the filter as needed (with any additional checks too) -Tim Antonio wrote

Throwing exception when including unexisting resource

2008-10-22 Thread Antonio
Hi all, I am a Tiles developer and I am struggling to resolve a problem in Tiles, that is reflected from a "gap" in the servlet specifications: https://issues.apache.org/struts/browse/TILES-320 What I want to do is to throw an exception whenever an included (through the use of RequestDispatcher.inc