I'm trying to create a portal that is complete utf-8.
My application is separate in a JBossPortlet that is preparing all ejb3 and
then redirect the request on a JSP.
To configure the utf-8 charset:
1) I save the jsp file in utf-8 format.
2) I place response.setContentType("text/html;charset=utf-8") at the beginning
of the doView method in the portlet
The portlet is like that:
public void doView (JBossRenderRequest request, JBossRenderResponse response)
throws PortletException, IOException
| {
| response.setContentType("text/html;charset=utf-8");
| request.setAttribute("eacute", "é");
| request.setAttribute("eacute2", "\uc3a9");
| PortletRequestDispatcher rd =
getPortletContext().getRequestDispatcher(page.jsp);
| rd.include(request, response);
| }
The JSP page.jsp that is save on the utf-8 format
<%@ page language="java" %>
| <%@ taglib uri="/WEB-INF/tld/c-rt.tld" prefix="c" %>
| <p>
| é <br>
| ${eacute}
| ${eacute2}
| </p>
And the result is that the browser (IE) detect the correct file format and
print the page in utf-8.
The first e is printing right (because the jsp is right encode)
The second e is printing wrong, I get a chinese caracter. If I'm looking inside
the hexacode of the file, I can find that the é had the code E9. E9 is the
ASCII code of é, so what I think is that the é that is comming from the portlet
have not been converted to utf-8.
The third e is a '?', and I don't know why...
Looking inside many documentation I find that for Servlet the method
setContentType will convert every output to the charset specified. Is it the
same for portlet ?? Should I configure something else ??
I find that for servlet, it's possible to do this:
PrintWriter out = new PrintWriter(new
OutputStreamWriter(response.getOutputStream(), "UTF8"), true);Can I do somthing
similar with portlets ?
To resume, I don't know how to print in a good way the String that are comming
from the java code? If someone have already turn in this problem, it would be
great. thanks in advance
David
Note: Sorry for my bad english :(
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3895990#3895990
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3895990
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user