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

Key: WW-638
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Mathias Bogaert
Reporter: Quake Wang
Votes: 1
Watchers: 0
Operations

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

Freemarker result encoding error

Created: 13/Sep/04 03:09 AM   Updated: 23/Nov/04 07:51 AM
Component/s: Views
Affects Version/s: 2.1.1
Fix Version/s: 2.1.7

Environment:
Jetty 4.2.19
j2sdk 1.4.1_02


 Description  « Hide
The character encoding is broken when use freemarker as template result, after change the FreemarkerResult's getWriter method to use response writer directly, it works:

old:
protected Writer getWriter() throws IOException {
    return new OutputStreamWriter(ServletActionContext.getResponse().getOutputStream());
}

new:
protected Writer getWriter() throws IOException {
    return ServletActionContext.getResponse().getWriter();
}


 All   Comments   Change History      Sort Order:
Mathias Bogaert - [12/Nov/04 04:17 PM ]
Richard, can you tell me if this 'patch' is correct? I'm scared it might break other stuff.

Richard HALLIER - [12/Nov/04 07:57 PM ]
/**
     * the default writer writes directly to the response output stream
     */
    protected Writer getWriter() throws IOException {
        return ServletActionContext.getResponse().getWriter();
    }

I've read the code and I can confirm the above snippet is correct.
Richard.

Mathias Bogaert - [18/Nov/04 08:33 AM ]
Didn't use getWriter (since only getWriter OR getOutputStream is used, was same issue for SiteMesh). Fixed by doing

protected Writer getWriter() throws IOException {
        return new OutputStreamWriter(
                ServletActionContext.getResponse().getOutputStream(),
                ServletActionContext.getResponse().getCharacterEncoding()
        );
    }