History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-159
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Andres March
Reporter: Andres March
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OSCache

CacheFilter does not set encoding properly

Created: 31/Mar/05 02:31 PM   Updated: 12/Apr/05 11:34 AM
Component/s: Filters
Affects Version/s: 2.1
Fix Version/s: 2.1.1

Issue Links:
Duplicate
This issue duplicates:
CACHE-38 oscache filter doesn't support correc... Critical Closed
 


 Description  « Hide
The cachefilter does not set the encoding properly; therefore, multibyte characters may not be written properly.

 All   Comments   Change History      Sort Order:
Andres March - [31/Mar/05 02:32 PM ]
Subject: Re: OSCache wrong; SiteMesh 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

Andres March - [31/Mar/05 02:39 PM ]
Thanks for getting that in.

Lars Torunski - [31/Mar/05 03:15 PM ]
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.

Andres March - [12/Apr/05 11:31 AM ]
I'm working on this. Something is not right.

Andres March - [12/Apr/05 11:34 AM ]
duplicate of CACHE-38