encoding problem with Struts

M

Malcolm

Hi, all.

I was wondering if someone could tell me what i do wrong. I've got a
web-application (i use Struts 1.1) and i need to print strings
containing data in russian. This is the page-source, but it prints
invalid data ('?' characters istead of russian symbols).

<%@ page language="java" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:html locale="true">
<head>
<html:base />
<title><bean:message key="show.title" /></title>
</head>
<body>
<h2><bean:message key="show.top" /></h2>
<hr width="400" align="left" />
<logic:iterate id="article" collection="<%= ((java.util.LinkedList)
request.getAttribute("results")).iterator() %>">
<p>
<b>
<bean:write name="article" property="headline" />
</b>
[<bean:write name="article" property="topic" />]<br />
<i>
<bean:write name="article" property="magazineName" />--
<bean:write name="article" property="issue" />
</i><br />
<bean:write name="article" property="body" />
</p>
</logic:iterate>
</body>
</html:html>

Such behaviour looks like printing unicode symbols in ISO-8859-1. How
can I change the default charset of output. I didn't manage to do it by
just putting the <meta> tag specifing charset of Cp1251. May be I can
set the encoding of the page to UTF-8, for example. Is it possible by
editing Struts config files?

Thanks for any advice!

Best regards, Yevgen Malafeyev AKA Malcolm.
 
M

Manish Jethani

Malcolm said:
I was wondering if someone could tell me what i do wrong. I've got a
web-application (i use Struts 1.1) and i need to print strings
containing data in russian. This is the page-source, but it prints
invalid data ('?' characters istead of russian symbols).

<%@ page language="java" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<%@ page contentType="text/html; charset=utf-8" %>

[snip]

That should be it.

-Manish
 
M

Malcolm

Hi Manish,

Manish Jethani ?????:
<%@ page contentType="text/html; charset=utf-8" %>

It changed the codepage of the output. But it seems the strings are
printed not in the codepage set for the web-page but in system coding
(koi8-r in my case). Is it possible to force tomcat (or Struts) to print
the String using codepage of the corresponding web-page or other
codepage. For example I tried to print str.getBytes("Cp1251"), but it
printed junk.

Thanks for your answer.

Best regards, Yevgen Malafeyev AKA Malcolm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top