|
|
|
Changes were done in the current CVS HEAD of OSCache 2.2 first and then backported to the 2.1.1 branch.
Because a few issues were implemented for the release 2.2 before, I tried to minimize my modifications in the 2.1.1 branch. I'm working on this. Something is not right.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
According to Jayson Falkner and his book(s) "Servlets and JavaServer
pages; the J2EE Web Tier" we have to change the line to
cachedWriter = new PrintWriter(new
OutputStreamWriter(getOutputStream(), result.getContentEncoding()));
in CacheHttpServletResponseWrapper and we have to add a getter method in
ResponseContent
public String getContentEncoding() {
return contentEncoding;
}
Patrick Lightbody wrote:
>Joe's suggestion sounds spot-on. I'm going to modify 2.0.2 and try it
>out now.
>Subject: Re: OSCache wrong; SiteMesh right?
>
>I see. There is behavior added in the getOutputStream() and that is
>what is being wrapped. The super writer will write to the original
>output stream not the caching one. The encoding might be the issue and
>is a problem either way. I'll get it fixed this weekend.
>
>Joe Walnes wrote:
>
>
>
>>First thing to do is prove which filter is correct. Try the web-app
>>with both filters, then each of them individually, then neither, to
>>narrow it down.
>>
>>I suspect the problem is that in
>>CacheHttpServletResponseWrapper.getWriter(), a new PrintWriter is
>>created wrapped around the ServletOutputStream, but it's not taking
>>into account the encoding.
>>
>>I reckon the problem might go away if you change this:
>>
>> cachedWriter = new PrintWriter(getOutputStream());
>>
>>... to this:
>>
>> String encoding = result.getContentEncoding(); cachedWriter = new
>>PrintWriter(new ObjectOutputSteam(getOutputStream(), encoding));
>>
>>(or whatever you need to do to figure out the encoding)
>>
>>In SiteMesh we have to take into account that one request may have
>>content written to both the outputstream and the writer, which is
>>technically illegal in the Servlet API, but because SiteMesh munges
>>multiple requests into one, we have to do some magic. However, I doubt
>>this is necessary in OSCache, assuming the OSCache filter is applied
>>before the SiteMesh filter.
>>
>>-joe
>>
>>On Thu, 31 Mar 2005 17:35:57 +1000, Scott Farquhar
>>
>>
>>
>>>On Wed, Mar 30, 2005 at 08:53:25PM -0800, Andres wrote:
>>>
>>>
>>>
>>>
>>>>All getWriter() does is create a PrintWriter that wraps the output
>>>>stream but the super.getWriter() should already do that. Unless I'm
>>>>missing something this is convoluted and unnecessary object
creation.
>>>>If the new CacheHttpServletResponseWrapper's private writer field
>>>>somehow adds behavior that the super's writer field does not, I do
>>>>not see it.
>>>>
>>>>
>>>>
>>>>
>>>This is not the case. The super method will not wrap around
>>>getOutputStream(), hence the need for this method in the filter.
>>>
>>>I haven't had a chance to look at it, but I'd back the sitemesh way -
>>>we've spent a long time trying to get the best method of working
>>>inside of sitemesh, and it has been tested for i18n on almost all
>>>
>>>
>containers.
>
>
>>>Cheers,
>>>Scott