• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Displaying Non english content in a UTF-8 JSP

 
Rosemary George
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am tryign to internationalize our product and is making it UTF-8 enabled.We are working using J2EE,JSPS and IBM websphere 5.0.2 as the application server.
For non enlgish content to be displayed properly I have set the content type using
<%@ page contentType="text/html; charset=UTF-8" %>
What we have did is put this line in a common jsp and have included common.jsp in all the other jsps
This is done for the ease of changing the charset if needed just at one place
With this setup my dynamic content which comes from the DataBase(which is Unicode enabled) works well.
But the static content which I put in the jsp has a problem.
The static non english content gets displeyd properly for only the jsps which has
<%@ page contentType="text/html; charset=UTF-8" %> set in it.
If this is set in some included jsp then the static content comes as junk .
That is, the static content comes properly if and only if I have the line <%@ page contentType="text/html; charset=UTF-8" %> in my jsp and not in any jsp which I have included.
Could anyone tell me if there is a solution to this?
Note1:All Non english jsps are saved as UTF-8
Note 2:If i give META tag it works but
I do not want to use META tag,'cause I want my content to be converted to UTF-8 explicity or else my dynamic content will not work.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wrote: The static non english content gets displeyd properly for only the jsps which has
<%@ page contentType="text/html; charset=UTF-8" %> set in it.
If this is set in some included jsp then the static content comes as junk .

Can you tell us which sort of "include" you are using to include this code?
If you are using any of the "request-time" includes (<jsp:include> <c:import>, web.xml prelude etc.) this won't work. You need to make sure that you only use the "compile-time" include ( <%@include%> ) if you want to include directives.
 
Rosemary George
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frank,
I am using compile time include itself.
<%@ include file="common.jsp" %> is what I am using.
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
folks,
i ran into the same problem couple of days ago and i didn't find any explanation for such a behavior. why setting content type and character set has an influence only if done in the jsp file itself, and not in another included jsp file?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of include are you using?
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@include..

by the way, request.setContentType() placed in the included file works just fine. the data delivered in request is ok. but the static data is displayed right only if the page attribute is placed in the file itself, and not in the included one.
[ March 22, 2006: Message edited by: Asher Tarnopolski ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!