You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Hamrita Sami <Sa...@eon-energie.com> on 2004/09/02 16:50:23 UTC

Struts and Escaping Special Charachters in HTML

Hello,

does Struts support escaping special charachters for HTML GUIs (e.g. ü -->
&uuml;) when using its custom tags library? 
If yes, how to enable that feature then? 

Cheers,
Sami


Re: Struts and Escaping Special Charachters in HTML

Posted by Joe Germuska <Jo...@Germuska.com>.
At 4:50 PM +0200 9/2/04, Hamrita Sami wrote:
>Hello,
>
>does Struts support escaping special charachters for HTML GUIs (e.g. ü -->
>&uuml;) when using its custom tags library?
>If yes, how to enable that feature then?

Struts doesn't convert characters to HTML 
entities.  Instead, you should control the 
character encoding of your pages so that the 
characters can be displayed correctly without 
entities.

A general easy way to do this with JSPs is to set 
the content-type of the page with a JSP @page 
directive like this:

<%@ page contentType="text/html; charset=UTF-8" %>

Of course, you may need to use a different 
charset, but UTF-8 is a pretty good default.

There are other ways to set the character 
encoding, but this one is simplest to me.  Note 
that if you use tiles or other JSP include 
strategies, only the first content-type is 
honored - it is ignored in pages that write to an 
output stream that already has been "started".

Hope this helps.
	Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love 
Supreme,' I'll turn back; I'll know I'm in the 
wrong place."
    - Carlos Santana