Hi, Andrei!

You may consider looking at existing "mock" implementations of
HttpServletRequest/Response that are available.

For example, Spring Framework (http://springframework.org) has
org.springframework.mock.web.MockHttpServletRequest,
org.springframework.mock.web.MockHttpServletResponse

Those are in spring-mock.jar if you download Spring.

Some testing frameworks also have similar objects.

I used MockHttpServletResponse to catch and ignore output from a
subrequest in my webapp, but it was in the context of request/response
processing, and the original request was available there to perform
the call.

I suppose that you cannot use a mock request in such a way, because
it has a lot of information with it. E.g. how are you going to implement
request.getRequestDispatcher()? There can be also other issues,
e.g. attributes of the request may store additional information,
that may be required to process the request. You may learn from
the code though.

These mock objects are used to test how the framework behaves outside
of a servlet container. They are not intended to fool the container.

You also cannot use some earlier request/response. When the session times out,
that event has no relation to any requests being processed by the server at
the moment.

You may also open a new connection, using URL.openConnection(), but that
is too much overhead for your task. You should consider rewriting your audit
logic.

Best regards,
Konstantin

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to