You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by ch...@uvic.ca on 2004/06/11 05:17:01 UTC

#parse() and UTF-8 output problem

Hi,

In my web application, I have a Controller servlet which extends Velocity
Servlet. In the Controller servlet, I have

// set the request/response encoding once and for all
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");

This has been working great, the HTML rendered is in UTF-8.

However, today I modified template so that the common parts get extracted.
So, instead of

<html>
<body>
content
</body>
</html>

I have

#parse("include/header.vm")
content
#parse("include/footer.vm")

But, when I run the web app, the browser displays two weird characters in
the html. When I looked at the html source, it is like

<html><body>
content
....

So there is no newline between <html><body> which was in the header.vm.

When I take the response.setxxxx() encoding off and run the app again, the
html page is good again.

So, I guess the encoding messed up the #parse() somehow. But could not
figure this out.

Any help is greatly appreciated!

Jian

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org