Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in setting character encoding in JSP

 
Mina Syal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am setting up character encoding in JSP dynamically using following meta tag:

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=<%=charset%>"

if charset value comes Big5 then it become
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Big5">

but browser is always showing contents in ASCII and not the encoding set by my JSP.
When I manually select View-->Encoding-->Chinese Traditional (Big5) in my Internet Explorer, it works.

Please help.

Thanks in advance,
Mina.
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe this will help

<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
 
Mina Syal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added following line in my jsp:

response.setContentType("text/html;charset"+scharset);


and now its working fine.


Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic