Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > encoding problem with Struts

Reply
Thread Tools

encoding problem with Struts

 
 
Malcolm
Guest
Posts: n/a
 
      07-25-2003
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.

 
Reply With Quote
 
 
 
 
Manish Jethani
Guest
Posts: n/a
 
      07-25-2003
Malcolm wrote:

> 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

--
Manish Jethani (manish.j at gmx.net)
phone (work) +91-80-51073488

 
Reply With Quote
 
 
 
 
Malcolm
Guest
Posts: n/a
 
      07-26-2003
Hi Manish,

Manish Jethani ?????:
>>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" %>


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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Text File Encoding and converting to Perls internal UTF-8 encoding sln@netherlands.com Perl Misc 2 04-17-2009 11:22 PM
changing JVM encoding; setting -Dfile.encoding doesn't work pasmol@plusnet.pl Java 1 10-08-2004 09:50 PM
Tomcat 5.028 Struts problem - struts-config.xml does not start with a "/" character Aleksandar Matijaca Java 2 09-19-2004 03:52 PM
Encoding.Default and Encoding.UTF8 Hardy Wang ASP .Net 5 06-09-2004 04:04 PM
parameters encoding & struts Malcolm Java 1 07-30-2003 11:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57