2015-07-17 18:48 GMT+03:00 Mitch Claborn <mitch...@claborn.net>:
>
> I spent some time yesterday digging through code without much luck. Today
> I'm going to experiment with this: getting a Request Dispatcher for the URL
> from the ServletContext, creating a dummy ServerRequest and ServerResponse
> object and invoking include(request, response) or forward() on that
> dispatcher.  With luck, I'll be able to get what would be the response from
> a HEAD or a GET request in some sort of output stream in the response
> object, then examine that output stream for the result.


Using dummy objects with those APIs is disallowed by Servlet specification.

If you run in "strict compliance mode", Tomcat will check this
requirement. As far as I remember, the error message mentions the
chapter number of specification.

http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html#Specification
See for "WRAP_SAME_OBJECT"


Testing for existence of static pages should be easy, with
ServletContext.getResource[AsStream]() or with other APIs (using
Tomcat internal resources APIs, or accessing the files directly)

Testing for existence of dynamic pages may be hard. You cannot check
for existence unless making an actual request (better with a HEAD
request rather than with a GET).

If you are unlucky, a GET request may trigger some action. E.g. Tomcat
Manager application was suffering from such feature,
https://bz.apache.org/bugzilla/show_bug.cgi?id=50231

A HEAD request is better, as it produces no output, but e.g. for JSPs
a HEAD request is implemented as GET + suppressing output, so it
actually performs the same processing.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to