Hello Magnolians 

I have to pick up this old thread since I'm currently fighting the same battle.


I'm rather unsure about the possible solutions Jan promoted:

1. "either find out which filter/servlet called it and disable it or put your 
servlet in front of it"

-> I'm not sure how I would find the filter/servlet that called it other than 
wading through the source - however even if I'd know which one it was, 
disabling seems not to be an option since I might wreck some general 
functionality.
For the "put your servlet in front" bit: I figured the only way making the 
subtemplating work is to define the servlet in the web.xml - there I put it at 
the very beginning which did not change anything. And even if it would be 
called first wouldn't that mean that the exception would just get thrown 
further down the road?


2. "or use getWriter() method and work with a writer in your servlet rather 
then with OutputStream ... There are wrappers around that let you wrap Writer 
into OutputStream and vice-versa so you can use that to work around the issue"
-> I was looking around the web for some time now but could not find anything - 
so if you have a concrete pointer I would appreciate it very much!


Now what I tried furthermore is to simply reset the response prior to generate 
by PDF output through "response.reset();". This worked fine (although I'm not 
fond at all with this idea) until I activated the cache.
Then I hit the following exception:

2010-04-26 08:35:53,988 DEBUG ch.tmit.PdfWriterStandard                     : 
Generating output for :textAndImage
2010-04-26 08:35:53,994 ERROR info.magnolia.module.cache.executor.Store         
: Failed to process cache request : Can't get Last-Modified header : no or 
multiple values : null
java.lang.IllegalStateException: Can't get Last-Modified header : no or 
multiple values : null
        at 
info.magnolia.module.cache.filter.CacheResponseWrapper.getLastModified(CacheResponseWrapper.java:139)
        at 
info.magnolia.module.cache.executor.Store.makeCachedEntry(Store.java:161)
        at 
info.magnolia.module.cache.executor.Store.processCacheRequest(Store.java:115)


I know that these are all just dangling loose ends - but I really hit a dead 
end here and need a way to get this running again.

Many thanks for any help!
Cheers, Thomas


On 15.07.2009, at 23:21, Jan Haderka wrote:

> 
> On Wed, 2009-07-15 at 22:58 +0200, Tobias Reinhardt wrote:
>> Hi
>> 
>> I am trying to output a PDF with a template of type servlet. I get the
>> "getWriter() has already been called for this response" Error when I
> 
> I think the message is pretty clear ... the getWriter() method has been
> already called. You can't use both getOutputStream() and getWriter() on
> the response ... it seems in 4.1 some filter or servlet executed before
> your servlet has already called getWriter() on the response so you can't
> use getOutputStream() anymore ... either find out which filter/servlet
> called it and disable it or put your servlet in front of it ... or use
> getWriter() method and work with a writer in your servlet rather then
> with OutputStream ... There are wrappers around that let you wrap Writer
> into OutputStream and vice-versa so you can use that to work around the
> issue.
> 
> HTH,
> Jan
>> call response.getOutputStream(). I reduced the servlet to the bare
>> minimum.
>> 
>> public class TestServlet extends HttpServlet {
>>    public void doGet(HttpServletRequest request, HttpServletResponse
>> response) throws IOException, ServletException {
>>        response.getOutputStream();
>>    }
>> }
>> 
>> This servlet does generate the error on 4.1, but it does not generate
>> an error on 3.6.5.
>> 
>> Any ideas?
>> 
>> Tobias
>> 
>> ----------------------------------------------------------------
>> For list details see
>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>> To unsubscribe, E-mail to: <[email protected]>
>> ----------------------------------------------------------------
> -- 
> Best regards,
> 
> Jan Haderka
> Magnolia International Ltd.
> 
> Meet us at the Magnolia Conference
> http:/www.magnolia-cms.com/conference
> 
> Magnolia®  - Simple Open Source Content Management
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
> 


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to