• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi frank,
I am using compile time include itself.
<%@ include file="common.jsp" %> is what I am using.
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What type of include are you using?
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic