You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by Naresh Shorey <Na...@mwh.gov.bh> on 2008/06/03 12:51:51 UTC

pluto-1.1.5 : String encoding is changing when jsp is included

Any help to resolve this issue is most welcome.

I created a small HelloWorldPortlet which includes a jsp page

	public class HelloWorldPortlet extends GenericPortlet {
	    protected void doView(RenderRequest request, 
      	                    RenderResponse response) throws PortletException, 
	                                                          IOException {
	        response.setContentType("text/html; charset=UTF-8");
	        //this.getPortletContext().getRequestDispatcher("/greet").include(request, response);
		  this.getPortletContext().getRequestDispatcher("/msg.jsp").include(request, response);
	    }
	}
The jsp page msg.jsp outputs a string in unicode:
	<%@ page contentType="text/html;charset=UTF-8"%>
	<p>Hello Portlet. 
	<% String s = "\u0645\u0631\u062d\u0628\u0627"; %>
	<br/>Printing Unicode from jsp : <%=s%>
	<br/>
	<% out.println("file.encoding = " + System.getProperty("file.encoding")); %>
	</p>

I am using Pluto-1.1.5 as driver to render the portlet and the unicode string is not being displayed as expected. The String is text in Arabic language. It seems that Pluto is converting the string to Cp1252 encoding.

The same text is rendered fine if we include a servlet which outputs this text instead of a jsp.
	public class Greet extends HttpServlet {
	    private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
	    public void init(ServletConfig config) throws ServletException {
	        super.init(config);
	    }
	
	    public void doGet(HttpServletRequest request, 
	                      HttpServletResponse response) throws ServletException, IOException 	{						  response.setContentType(CONTENT_TYPE);
	        PrintWriter out = response.getWriter();
	        out.println("Printing Unicode from servlet : " + "\u0627\u0646\u062a\u0647\u0627\u0621");
	        out.close();
	    }
	}



Best Regards,

Naresh Shorey

Re: pluto-1.1.5 : String encoding is changing when jsp is included

Posted by CD...@hannaford.com.

Hi Naresh,
Try setting the charset init-param for PortalDriverServlet in web.xml as
described here: https://issues.apache.org/jira/browse/PLUTO-446 .
/Craig





                                                                           
             "Naresh Shorey"                                               
             <Naresh@mwh.gov.b                                             
             h>                                                         To 
                                       <pl...@portals.apache.org>      
             06/03/2008 06:51                                           cc 
             AM                                                            
                                                                   Subject 
                                       pluto-1.1.5 : String encoding is    
             Please respond to         changing when jsp is included       
             pluto-dev@portals                                             
                .apache.org                                                
                                                                           
                                                                           
                                                                           
                                                                           




Any help to resolve this issue is most welcome.

I created a small HelloWorldPortlet which includes a jsp page

             public class HelloWorldPortlet extends GenericPortlet {
                 protected void doView(RenderRequest request,
                                       RenderResponse response) throws
PortletException,

IOException {
                     response.setContentType("text/html; charset=UTF-8");

//this.getPortletContext().getRequestDispatcher("/greet").include(request,
response);

this.getPortletContext().getRequestDispatcher("/msg.jsp").include(request,
response);
                 }
             }
The jsp page msg.jsp outputs a string in unicode:
             <%@ page contentType="text/html;charset=UTF-8"%>
             <p>Hello Portlet.
             <% String s = "\u0645\u0631\u062d\u0628\u0627"; %>
             <br/>Printing Unicode from jsp : <%=s%>
             <br/>
             <% out.println("file.encoding = " +
System.getProperty("file.encoding")); %>
             </p>

I am using Pluto-1.1.5 as driver to render the portlet and the unicode
string is not being displayed as expected. The String is text in Arabic
language. It seems that Pluto is converting the string to Cp1252 encoding.

The same text is rendered fine if we include a servlet which outputs this
text instead of a jsp.
             public class Greet extends HttpServlet {
                 private static final String CONTENT_TYPE = "text/html;
charset=UTF-8";
                 public void init(ServletConfig config) throws
ServletException {
                     super.init(config);
                 }

                 public void doGet(HttpServletRequest request,
                                   HttpServletResponse response) throws
ServletException, IOException              {

response.setContentType(CONTENT_TYPE);
                     PrintWriter out = response.getWriter();
                     out.println("Printing Unicode from servlet : " +
"\u0627\u0646\u062a\u0647\u0627\u0621");
                     out.close();
                 }
             }



Best Regards,

Naresh Shorey