You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Theodosios Paschalidis <th...@hotmail.com> on 2004/01/23 16:11:05 UTC

Tomcat/Struts Unicode Encoding/Decoding problems

Hi all,

I am trying to setup a database driven web site that displays unicode characters. I have spent much time on this but my attempts have been unsuccessful.

I have tested my JDBC business logic with the database and works fine but when I use my application to perform a search it fails to find anything, ie it does not correctly retrieve international characters. (It must be a struts/server issue) When I printout the string used, it appears mangled both in the Tomcat console and my JSP.
If I display Unicode characters retrieved from the database they again appear mangled. (Mind you that my UTF-8 encoded Message bundle displays fine on the same page!)

Here is what I have done.

JSP setup
========

<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>

<html:form action="/DoSearch" focus="title" method="post" target="content" enctype="text/plain;charset=UTF-8" >

to change the server's decoding I used
<% request.setCharacterEncoding("UTF-8"); %>
before retrieving my form data


   out.print("RESPONSE character encoding=" +response.getCharacterEncoding()+" " );
   out.print("REQUEST character encoding=" +request.getCharacterEncoding()+" " );
   out.println("JVM encoding " +System.getProperty("file.encoding")+" ");
  
Reveals "UTF-8"  encoding for server response/request  and "Cp1253" (standard Greek windows code page) for the JVM. (could this be the problem? Is there a way to change this?)


Tomcat Setup
============
I have added the following in startup.bat

JAVA_OPTS=-Dfile.encoding="utf8"

CATALINA_OPTS=-Dfile.encoding="utf8"


Software components.
=========================
- OS: Microsoft Windows XP Pro
- Database: mysql-4.1.1
- JDBC: mysql-connector-java-3.1.0
- Web Server: jakarta-tomcat-4.1.24
- Framework: struts 1.1
- Development Tool: NetBeans 3.5

Should I be configuring something in struts instead? Maybe an encoding parameter in either web.xml or struts-html?

I am out of ideas so any help will be greatly appreciated.

Thank you for your time,
Theo

Re: problem with nested tags

Posted by Claire Wall <cl...@kurtosys.com>.
You cannot have custom tags within custom tags. As you say you want a
<bean:write> tag within an <html:button> tag, then this will not work as
they are both custom tags. You could get around this by using <bean:define>
and then using the value of this in your html:button tag like so:

<bean:define id="a" name="myForm" value="myValue"/>

<html:button value="<%= (String) a %>"/>

or indeed you could do something like this:

<html:button><bean:write.../></html:button> if you want to use the
<bean:write> for the name of the button.

I'm not certain as to how you are trying to use <bean:write./> in your
<html:button> tag as I dont see an example of it in your code, unless I'm
being completely dopey... :)

cheers
claire w


----- Original Message -----
From: "Marco Mistroni" <mm...@waersystems.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Monday, January 26, 2004 12:19 PM
Subject: problem with nested tags


> Hi all,
> I have problem in invoking a javascript for following code...
>
> <nested:iterate id="element" name="batchTaskForm" property="tasks">
>      <tr class="workscreen">
>        <td align="right" class="workscreen">
>         <bean:write name="element" property="value.type"/>
>    </td>
>        <td align="left" class="workscreen">
>
>
>         <nested:equal name="element" property="active"
> value="true">Active since <bean:write name="element"
> property="value.startDate"/>
>
>               <html:button property="buttonSelected"
> value="start" title="Start" /> // I should associate this button with a
> javascript method          //that accepts as input
> parameter the type property //mentioned
> above
>         </html:form>
>         </nested:equal>
>
>     <nested:equal name="element" property="active"
> value="false">Currently Inactive <html:button property="buttonSelected"
> title="Start" value="start"/></nested:equal>
>    </td>
>      </tr>
>    </nested:iterate>
>
>
> For some reason, the bean:write tag does not work inside an html:button
> ...
>
> Anyone can help?
>
> Thanx in advance and regards
> marco
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


problem with nested tags

Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
	I have problem in invoking a javascript for following code...

<nested:iterate id="element" name="batchTaskForm" property="tasks">
	     <tr class="workscreen">
	       <td align="right" class="workscreen">
	        <bean:write name="element" property="value.type"/>
		   </td>
	       <td align="left" class="workscreen">
	        
	        
	        <nested:equal name="element" property="active"
value="true">Active since <bean:write name="element"
property="value.startDate"/> 
	              
	              <html:button property="buttonSelected"
value="start" title="Start" /> // I should associate this button with a
javascript method          			//that accepts as input
parameter the type property 				//mentioned
above
	        </html:form>		
	        </nested:equal>
	        
		    <nested:equal name="element" property="active"
value="false">Currently Inactive <html:button property="buttonSelected"
title="Start" value="start"/></nested:equal>
		   </td>
	     </tr>    
	   </nested:iterate>	


For some reason, the bean:write tag does not work inside an html:button
...

Anyone can help?

Thanx in advance and regards
	marco


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Logic:iterate and logic:equalquestion

Posted by Nicolas De Loof <ni...@cgey.com>.
Solution 1 : 
<bean:define id="myObject" name="element" property="value"/>
<logic:equal name="myObject" property="status" value="true">Active</logic:equal>
...

Solution 2 : 
<logic:equal name="element" property="value.status" value="true">Active</logic:equal>
...


Nico.


> Hi all,
> I need to use the logic:equal inside a logic iterate..and I am
> Having problems..
> My case is that I hae in an ActionForm an HashMap property which
> contains
> Pairs of  String, MyObject.  My object has a Boolean property called
> status
> 
> What I want to do is to loop thru all the objects in my hashmap and, if
> the property status has a value of true I want to display button A,
> while if it is false I want to display button B.
> 
> For testing purposes I am now displaying some text...
> 
> 
> I tried with following loop, but seems that is not working properly
> 
> // Loop thru all the objects contained in the hashmap
> <logic:iterate id="element" name="batchTaskForm" property="tasks"> 
>   <tr class="workscreen">
>      <td align="right" class="workscreen">
>     
> // Here I got myObject   , and its property 'type'
> 
>      <bean:write name="element" property="value.type"/>
>      </td>
>      <td align="left" class="workscreen">
>        
> // Now I should reuse MyObject here....but below code raises
> // exception (obviously)
> 
> <logic:equal name="element" property="status"
> value="true">Active</logic:equal>
>     <logic:equal name="element" property="status"
> value="false">Inactive</logic:equal>
>      
>    </td>
>      </tr>    
> </logic:iterate>
> 
> I believe I should go for a bean:define  tag but I m not sure how to use
> it
> 
> Anyone can help?
> 
> Thanx in advance and regards
> marco
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Logic:iterate and logic:equalquestion

Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
	I need to use the logic:equal inside a logic iterate..and I am
Having problems..
My case is that I hae in an ActionForm an HashMap property which
contains
Pairs of  String, MyObject.  My object has a Boolean property called
status

What I want to do is to loop thru all the objects in my hashmap and, if
the property status has a value of true I want to display button A,
while if it is false I want to display button B.

For testing purposes I am now displaying some text...


I tried with following loop, but seems that is not working properly

// Loop thru all the objects contained in the hashmap
<logic:iterate id="element" name="batchTaskForm" property="tasks"> 
  <tr class="workscreen">
     <td align="right" class="workscreen">
    
// Here I got myObject   , and its property 'type'

     <bean:write name="element" property="value.type"/>
     </td>
     <td align="left" class="workscreen">
       
// Now I should reuse MyObject here....but below code raises
// exception (obviously)

	 <logic:equal name="element" property="status"
value="true">Active</logic:equal>
		    <logic:equal name="element" property="status"
value="false">Inactive</logic:equal>
		     
		   </td>
	     </tr>    
</logic:iterate>

I believe I should go for a bean:define  tag but I m not sure how to use
it

Anyone can help?

Thanx in advance and regards
	marco




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Tomcat/Struts Unicode Encoding/Decoding problems

Posted by Jim Theodoridis <st...@tera.gr>.
Proxora!!!

I am getting the same error but everthing work FINE
This error displayed since tomcat 4.1.24 but it works


----- Original Message -----
From: "Theodosios Paschalidis" <th...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 5:54 PM
Subject: Re: Tomcat/Struts Unicode Encoding/Decoding problems


> Gia sou patriwti!
>
> I am grateful for your help. Unfortunately I get an XML validation error
> when I copy that code in my application's web.xml
>
> The content of element type "web-app" must match
>
"(icon?,display-name?,description?,distributable?,context-param*,servlet*,se
>
rvlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,
>
taglib*,resource-ref*,security-constraint*,login-config?,security-role*,env-
> entry*,ejb-ref*)". [151]
>
> here is the beginning of my xml document.
>
> <!DOCTYPE web-app
>
>   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
>
>   "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> Any ideas?
>
> Cheers,
> Theo
>
> ----- Original Message -----
> From: "Jim Theodoridis" <st...@tera.gr>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Friday, January 23, 2004 3:37 PM
> Subject: Re: Tomcat/Struts Unicode Encoding/Decoding problems
>
>
> > Geia
> >
> > U must define a filter in your web.xml so all character encoding in
UTF-8
> > LIKE THIS ....
> > for more visit www.anassina.com/struts/i18n/i18n.html
> >
> > I work in MySQL 3.23 with out problem
> >
> >         <filter-name>Set Character Encoding</filter-name>
> >         <filter-class>filters.SetCharacterEncodingFilter</filter-class>
> >         <init-param>
> >             <param-name>encoding</param-name>
> >             <param-value>UTF-8</param-value>
> >         </init-param>
> >     </filter>
> >
> >     <!-- Define filter mappings for the defined filters -->
> >     <filter-mapping>
> >         <filter-name>Set Character Encoding</filter-name>
> >  <servlet-name>action</servlet-name>
> >     </filter-mapping>
> >
> >
> >
> > ----- Original Message -----
> > From: "Theodosios Paschalidis" <th...@hotmail.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Friday, January 23, 2004 5:11 PM
> > Subject: Tomcat/Struts Unicode Encoding/Decoding problems
> >
> >
> > Hi all,
> >
> > I am trying to setup a database driven web site that displays unicode
> > characters. I have spent much time on this but my attempts have been
> > unsuccessful.
> >
> > I have tested my JDBC business logic with the database and works fine
but
> > when I use my application to perform a search it fails to find anything,
> ie
> > it does not correctly retrieve international characters. (It must be a
> > struts/server issue) When I printout the string used, it appears mangled
> > both in the Tomcat console and my JSP.
> > If I display Unicode characters retrieved from the database they again
> > appear mangled. (Mind you that my UTF-8 encoded Message bundle displays
> fine
> > on the same page!)
> >
> > Here is what I have done.
> >
> > JSP setup
> > ========
> >
> > <%@ page contentType="text/html;charset=UTF-8" language="java"
> > pageEncoding="UTF-8" %>
> >
> > <html:form action="/DoSearch" focus="title" method="post"
target="content"
> > enctype="text/plain;charset=UTF-8" >
> >
> > to change the server's decoding I used
> > <% request.setCharacterEncoding("UTF-8"); %>
> > before retrieving my form data
> >
> >
> >    out.print("RESPONSE character encoding="
> > +response.getCharacterEncoding()+" " );
> >    out.print("REQUEST character encoding="
> +request.getCharacterEncoding()+"
> > " );
> >    out.println("JVM encoding " +System.getProperty("file.encoding")+"
");
> >
> > Reveals "UTF-8"  encoding for server response/request  and "Cp1253"
> > (standard Greek windows code page) for the JVM. (could this be the
> problem?
> > Is there a way to change this?)
> >
> >
> > Tomcat Setup
> > ============
> > I have added the following in startup.bat
> >
> > JAVA_OPTS=-Dfile.encoding="utf8"
> >
> > CATALINA_OPTS=-Dfile.encoding="utf8"
> >
> >
> > Software components.
> > =========================
> > - OS: Microsoft Windows XP Pro
> > - Database: mysql-4.1.1
> > - JDBC: mysql-connector-java-3.1.0
> > - Web Server: jakarta-tomcat-4.1.24
> > - Framework: struts 1.1
> > - Development Tool: NetBeans 3.5
> >
> > Should I be configuring something in struts instead? Maybe an encoding
> > parameter in either web.xml or struts-html?
> >
> > I am out of ideas so any help will be greatly appreciated.
> >
> > Thank you for your time,
> > Theo
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Tomcat/Struts Unicode Encoding/Decoding problems

Posted by Theodosios Paschalidis <th...@hotmail.com>.
Gia sou patriwti!

I am grateful for your help. Unfortunately I get an XML validation error
when I copy that code in my application's web.xml

The content of element type "web-app" must match
"(icon?,display-name?,description?,distributable?,context-param*,servlet*,se
rvlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,
taglib*,resource-ref*,security-constraint*,login-config?,security-role*,env-
entry*,ejb-ref*)". [151]

here is the beginning of my xml document.

<!DOCTYPE web-app

  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

Any ideas?

Cheers,
Theo

----- Original Message ----- 
From: "Jim Theodoridis" <st...@tera.gr>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 3:37 PM
Subject: Re: Tomcat/Struts Unicode Encoding/Decoding problems


> Geia
>
> U must define a filter in your web.xml so all character encoding in UTF-8
> LIKE THIS ....
> for more visit www.anassina.com/struts/i18n/i18n.html
>
> I work in MySQL 3.23 with out problem
>
>         <filter-name>Set Character Encoding</filter-name>
>         <filter-class>filters.SetCharacterEncodingFilter</filter-class>
>         <init-param>
>             <param-name>encoding</param-name>
>             <param-value>UTF-8</param-value>
>         </init-param>
>     </filter>
>
>     <!-- Define filter mappings for the defined filters -->
>     <filter-mapping>
>         <filter-name>Set Character Encoding</filter-name>
>  <servlet-name>action</servlet-name>
>     </filter-mapping>
>
>
>
> ----- Original Message -----
> From: "Theodosios Paschalidis" <th...@hotmail.com>
> To: <st...@jakarta.apache.org>
> Sent: Friday, January 23, 2004 5:11 PM
> Subject: Tomcat/Struts Unicode Encoding/Decoding problems
>
>
> Hi all,
>
> I am trying to setup a database driven web site that displays unicode
> characters. I have spent much time on this but my attempts have been
> unsuccessful.
>
> I have tested my JDBC business logic with the database and works fine but
> when I use my application to perform a search it fails to find anything,
ie
> it does not correctly retrieve international characters. (It must be a
> struts/server issue) When I printout the string used, it appears mangled
> both in the Tomcat console and my JSP.
> If I display Unicode characters retrieved from the database they again
> appear mangled. (Mind you that my UTF-8 encoded Message bundle displays
fine
> on the same page!)
>
> Here is what I have done.
>
> JSP setup
> ========
>
> <%@ page contentType="text/html;charset=UTF-8" language="java"
> pageEncoding="UTF-8" %>
>
> <html:form action="/DoSearch" focus="title" method="post" target="content"
> enctype="text/plain;charset=UTF-8" >
>
> to change the server's decoding I used
> <% request.setCharacterEncoding("UTF-8"); %>
> before retrieving my form data
>
>
>    out.print("RESPONSE character encoding="
> +response.getCharacterEncoding()+" " );
>    out.print("REQUEST character encoding="
+request.getCharacterEncoding()+"
> " );
>    out.println("JVM encoding " +System.getProperty("file.encoding")+" ");
>
> Reveals "UTF-8"  encoding for server response/request  and "Cp1253"
> (standard Greek windows code page) for the JVM. (could this be the
problem?
> Is there a way to change this?)
>
>
> Tomcat Setup
> ============
> I have added the following in startup.bat
>
> JAVA_OPTS=-Dfile.encoding="utf8"
>
> CATALINA_OPTS=-Dfile.encoding="utf8"
>
>
> Software components.
> =========================
> - OS: Microsoft Windows XP Pro
> - Database: mysql-4.1.1
> - JDBC: mysql-connector-java-3.1.0
> - Web Server: jakarta-tomcat-4.1.24
> - Framework: struts 1.1
> - Development Tool: NetBeans 3.5
>
> Should I be configuring something in struts instead? Maybe an encoding
> parameter in either web.xml or struts-html?
>
> I am out of ideas so any help will be greatly appreciated.
>
> Thank you for your time,
> Theo
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Tomcat/Struts Unicode Encoding/Decoding problems

Posted by Jim Theodoridis <st...@tera.gr>.
Geia

U must define a filter in your web.xml so all character encoding in UTF-8
LIKE THIS ....
for more visit www.anassina.com/struts/i18n/i18n.html

I work in MySQL 3.23 with out problem

        <filter-name>Set Character Encoding</filter-name>
        <filter-class>filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>

    <!-- Define filter mappings for the defined filters -->
    <filter-mapping>
        <filter-name>Set Character Encoding</filter-name>
 <servlet-name>action</servlet-name>
    </filter-mapping>



----- Original Message -----
From: "Theodosios Paschalidis" <th...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Friday, January 23, 2004 5:11 PM
Subject: Tomcat/Struts Unicode Encoding/Decoding problems


Hi all,

I am trying to setup a database driven web site that displays unicode
characters. I have spent much time on this but my attempts have been
unsuccessful.

I have tested my JDBC business logic with the database and works fine but
when I use my application to perform a search it fails to find anything, ie
it does not correctly retrieve international characters. (It must be a
struts/server issue) When I printout the string used, it appears mangled
both in the Tomcat console and my JSP.
If I display Unicode characters retrieved from the database they again
appear mangled. (Mind you that my UTF-8 encoded Message bundle displays fine
on the same page!)

Here is what I have done.

JSP setup
========

<%@ page contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>

<html:form action="/DoSearch" focus="title" method="post" target="content"
enctype="text/plain;charset=UTF-8" >

to change the server's decoding I used
<% request.setCharacterEncoding("UTF-8"); %>
before retrieving my form data


   out.print("RESPONSE character encoding="
+response.getCharacterEncoding()+" " );
   out.print("REQUEST character encoding=" +request.getCharacterEncoding()+"
" );
   out.println("JVM encoding " +System.getProperty("file.encoding")+" ");

Reveals "UTF-8"  encoding for server response/request  and "Cp1253"
(standard Greek windows code page) for the JVM. (could this be the problem?
Is there a way to change this?)


Tomcat Setup
============
I have added the following in startup.bat

JAVA_OPTS=-Dfile.encoding="utf8"

CATALINA_OPTS=-Dfile.encoding="utf8"


Software components.
=========================
- OS: Microsoft Windows XP Pro
- Database: mysql-4.1.1
- JDBC: mysql-connector-java-3.1.0
- Web Server: jakarta-tomcat-4.1.24
- Framework: struts 1.1
- Development Tool: NetBeans 3.5

Should I be configuring something in struts instead? Maybe an encoding
parameter in either web.xml or struts-html?

I am out of ideas so any help will be greatly appreciated.

Thank you for your time,
Theo



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org