Hi, as you suggested, it is possible to capture output of handling request by subclassing HttpServletResponseWrapper, providing your own ServletOutputStream, and wrapping the original HttpServletResponse inside a filter on the requested processing pipeline. This way is not specific to Tapestry, maybe you only need to remember that Tapestry on the request processing pipeline is implemented as a filter, not a servlet. Tapestry itself uses this approach to implement compressing responses, see class org.apache.tapestry5.internal.gzip.GZipFilter. I don't know why it is not working for you, probably you have a bug, but without seeing your code it hard to help you.
Best regards, Cezary On Sat, Nov 30, 2019 at 10:38 AM Ric 2000 <erich.gorma...@gmail.com> wrote: > Dear all, > > I'm struggling on how to filter and modify the response sent to the client > in a Tapestry web application. > I tried first with a RequestFilter contributed to the RequestHandler > service. > The problem occurred when I tried to read the content of the current > response out stream. There are different hints on the internet how to do a > "capture" of this output stream using a custom HttpServletResponseWrapper > and overwriting the write method of the ServletOutputStream, to get the > current content of the outputstream as byte array. > > But this is always empty, regardless of how I try to do it. > > Can you tell me, what is the right way in Tapestry to do it? Which service > do I have to contribute, in which phase of the request processing the > response is filled and can be read, BEFORE it is send to the client? > > Thanks a lot for your suggestions, I really appreciate them! > > Best Regards, Ric >