2014-02-27 17:24 GMT+01:00 Konstantin Kolinko <knst.koli...@gmail.com>: > 2014-02-27 18:31 GMT+04:00 Jose María Zaragoza <demablo...@gmail.com>: >> >> And what do you recommend to me for forcing to return a Content-Type ? >> Some weird clients require it >> >> If I cannot do it with a Filter , where can I do it ? >> > > You can do it in a Filter. > > As I said, > 1. The header must be set before writing anything to the output > stream. That is per HTTP/1.1 protocol. > 2. The header must have correct value. > > How to implement that is up to you (do not expect me to teach you java > programming, but maybe others here will do). > > If you do not know the length before response is generated, a solution > can be to buffer the response before writing it out. > > Buffering can be done by writing an adapter around servlet response > that replaces default output stream with a buffered one. The adapter > can be implemented by extending > javax.servlet.http.HttpServletResponseWrapper class. Some caching > frameworks have filters that perform such buffering and caching.
Thanks. Finally, I did it with a servlet and it works I tried with a Filter and a HttpServletResponseWrapper. Long time before asking here. And I wrapped the response output stream into a FilterOutputStream , so I could count every byte written I got the right content length . All OK and I was happy. But , when I tried set the header with wrapper.setHeader("Content-Length", count ) , and as you told me before, the response headers had already been flushed ( i checked isCommited() ) I could modify output stream data but I couldn't modify response headers. I don't understand but it is Regards --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org