You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by mvalencia <mi...@juntadeandalucia.es> on 2010/10/05 14:26:56 UTC

problem encoding using SendMailTransformer

Hi all

  I have a problem using the code of:
org.apache.cocoon.mail.transformation.SendMailTransformer, when I send an
email, target user always receive the field body with strange characters, so
seemd bad encoding, and is curious only the field body, the subject is ok.

I work with encoding UTF-8, and I check Tomcat configuration is good:
 * parameter: URIEncoding="UTF-8"
 * SetCharacterEncoding = UTF-8
 * container-encoding = utf-8
 *  form-encoding = utf-8

I check encoding os serializers on Cocoon, too:
<map:serializer name="xml-utf8" mime-type="text/xml"
src="org.apache.cocoon.serialization.XMLSerializer">
  <encoding>UTF-8</encoding>
</map:serializer >
<map:serializer name="xhtml"
src="org.apache.cocoon.serialization.XMLSerializer">
          <doctype-public>-//W3C//DTD XHTML 1.0 Strict//EN</doctype-public>
         
<doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</doctype-system>
          <encoding>UTF-8</encoding>
</map:serializer>

I only see that There is any problem on AbstractSAXTransformer to recovery
data from textarea field on HTML, because is the diference between field
subject and body.

Thank you
-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29886850.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
Hi Andre

I load file with HTTP header of web page to send email:
http://old.nabble.com/file/p29914700/HTTP_header_Email-send.txt
HTTP_header_Email-send.txt 

I see that Accept-Charset parameter contains UTF-8 and in query-string data
are codified right.
Besides I check encoding browser is UTF-8.
-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29914700.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by Andre Juffer <an...@oulu.fi>.
On 10/08/2010 02:36 PM, mvalencia wrote:
> <map:parameter name="cuerpo" value="{request-param:id_cuerpo}" />
> can be the problematic part, since you take the value from the request.
>
> I can remember we applied the tips
> http://cocoon.apache.org/2.2/1366_1_1.html once in one of the apps.
> AFAIR there should be the  SetCharacterEncodingFilter in your code base.
>
>
> Yes, SetCharacterEncodingFilter is a filter defined on web.xml of Cocoon
> Application:
> <filter>
>      <filter-name>SetCharacterEncoding</filter-name>
>      <filter-class>
>        es.sadesi.filter.SetCharacterEncodingFilter</filter-class>
>      <init-param>
>        <param-name>encoding</param-name>
>        <param-value>UTF-8</param-value>
>      </init-param>
>    </filter>
> ......
> <filter-mapping>
>      <filter-name>SetCharacterEncoding</filter-name>
>      <servlet-name>DispatcherServlet</servlet-name>
>    </filter-mapping>
> .....
>
> I have test put encoding on HTML FORM, so with the parameter:
> accept-charset="UTF-8" on FORM tag, but it isn't work. It seems encoding
> lose when data go to block conector since Cocoon application, but I not
> sure.
>    

You could check whether the browser when it display the form to the user 
actually uses the correct encoding (UTF-8).

-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat                   | WWW: www.strubiocat.oulu.fi
NordProt                     | WWW: www.nordprot.org
Triacle Biocomputing         | WWW: www.triacle-bc.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
The form used get method, because with the post method not work the
"request-param" of Cocoon.

-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29931504.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by Thorsten Scherler <sc...@gmail.com>.
On Fri, 2010-10-08 at 04:36 -0700, mvalencia wrote:
> <map:parameter name="cuerpo" value="{request-param:id_cuerpo}" />
> can be the problematic part, since you take the value from the request.
> 
> I can remember we applied the tips
> http://cocoon.apache.org/2.2/1366_1_1.html once in one of the apps.
> AFAIR there should be the  SetCharacterEncodingFilter in your code base.
> 
> 
> Yes, SetCharacterEncodingFilter is a filter defined on web.xml of Cocoon
> Application:
> <filter>
>     <filter-name>SetCharacterEncoding</filter-name>
>     <filter-class>
>       es.sadesi.filter.SetCharacterEncodingFilter</filter-class>
>     <init-param>
>       <param-name>encoding</param-name>
>       <param-value>UTF-8</param-value>
>     </init-param>
>   </filter>
> ......
> <filter-mapping>
>     <filter-name>SetCharacterEncoding</filter-name>
>     <servlet-name>DispatcherServlet</servlet-name>
>   </filter-mapping>
> .....
> 
> I have test put encoding on HTML FORM, so with the parameter:
> accept-charset="UTF-8" on FORM tag, but it isn't work. It seems encoding
> lose when data go to block conector since Cocoon application, but I not
> sure.


are you using post or get for the form?

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
<map:parameter name="cuerpo" value="{request-param:id_cuerpo}" />
can be the problematic part, since you take the value from the request.

I can remember we applied the tips
http://cocoon.apache.org/2.2/1366_1_1.html once in one of the apps.
AFAIR there should be the  SetCharacterEncodingFilter in your code base.


Yes, SetCharacterEncodingFilter is a filter defined on web.xml of Cocoon
Application:
<filter>
    <filter-name>SetCharacterEncoding</filter-name>
    <filter-class>
      es.sadesi.filter.SetCharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
......
<filter-mapping>
    <filter-name>SetCharacterEncoding</filter-name>
    <servlet-name>DispatcherServlet</servlet-name>
  </filter-mapping>
.....

I have test put encoding on HTML FORM, so with the parameter:
accept-charset="UTF-8" on FORM tag, but it isn't work. It seems encoding
lose when data go to block conector since Cocoon application, but I not
sure.
-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29914526.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by Thorsten Scherler <sc...@gmail.com>.
On Wed, 2010-10-06 at 08:26 -0700, mvalencia wrote:
> This is the matches:
> 
> <map:match pattern="correopresidente.xml">
>   <map:act type="validator">
>     <map:parameter name="descriptor"
> value="{global:conectorXmlPath}correos/parametros-action-validator.xml"/>      	
>     <map:parameter name="validate-set" value="form-correo-presidente" />
>     <map:generate src="{global:conectorXmlPath}propmail.xml" />
>     <map:transform src="{global:conectorXslPath}constcorreopresidente.xsl">
>       <map:parameter name="nombre" value="{request-param:id_nombre}" />
>       <map:parameter name="apellido" value="{request-param:id_apellidos}" />
>       <map:parameter name="correo" value="{request-param:id_correo}" />
>       <map:parameter name="asunto" value="{request-param:id_asunto}" />
>       <map:parameter name="cuerpo" value="{request-param:id_cuerpo}" />
>     </map:transform>    
>     <map:transform type="sendmail" />
>     <map:serialize type="xml" />                 
>   </map:act>       
>   <map:generate
> src="{global:conectorXmlPath}correos/error-form-presidente.xml"/>        
>   <map:transform type="formTrans" />
>   <map:serialize type="xml" />           
> </map:match>
> 
> I comment transform "constcorreopresidente" y I put the value of field
> direct on file propmail.xml and the sendmail works OK. I change serializer
> to different charset but the problem isn't there.
> I think the problem is when the data are received on transform
> "constcorreopresidente" with request-param, because the program jump to
> sendmail (It is a class that extend from AbstractSAXTransformer, really is
> @version $Id: SendMailTransformer.java 607381 2007-12-29 05:42:58Z
> vgritsenko) then the field body has lost the encoding.
> 
> However I come back to do the test that you tell me.

<map:parameter name="cuerpo" value="{request-param:id_cuerpo}" />
can be the problematic part, since you take the value from the request.

I can remember we applied the tips
http://cocoon.apache.org/2.2/1366_1_1.html once in one of the apps.
AFAIR there should be the  SetCharacterEncodingFilter in your code base.

HTH

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
This is the matches:

<map:match pattern="correopresidente.xml">
  <map:act type="validator">
    <map:parameter name="descriptor"
value="{global:conectorXmlPath}correos/parametros-action-validator.xml"/>      	
    <map:parameter name="validate-set" value="form-correo-presidente" />
    <map:generate src="{global:conectorXmlPath}propmail.xml" />
    <map:transform src="{global:conectorXslPath}constcorreopresidente.xsl">
      <map:parameter name="nombre" value="{request-param:id_nombre}" />
      <map:parameter name="apellido" value="{request-param:id_apellidos}" />
      <map:parameter name="correo" value="{request-param:id_correo}" />
      <map:parameter name="asunto" value="{request-param:id_asunto}" />
      <map:parameter name="cuerpo" value="{request-param:id_cuerpo}" />
    </map:transform>    
    <map:transform type="sendmail" />
    <map:serialize type="xml" />                 
  </map:act>       
  <map:generate
src="{global:conectorXmlPath}correos/error-form-presidente.xml"/>        
  <map:transform type="formTrans" />
  <map:serialize type="xml" />           
</map:match>

I comment transform "constcorreopresidente" y I put the value of field
direct on file propmail.xml and the sendmail works OK. I change serializer
to different charset but the problem isn't there.
I think the problem is when the data are received on transform
"constcorreopresidente" with request-param, because the program jump to
sendmail (It is a class that extend from AbstractSAXTransformer, really is
@version $Id: SendMailTransformer.java 607381 2007-12-29 05:42:58Z
vgritsenko) then the field body has lost the encoding.

However I come back to do the test that you tell me.
-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29897843.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by Thorsten Scherler <sc...@gmail.com>.
On Tue, 2010-10-05 at 10:17 -0700, mvalencia wrote:
> Hi
> 
>   I did what you tell me, and the result is:

The first line (the xml declaration) is?

> <document>
> <sendmail>
> <smtphost>mail-int.andaluciajunta.es</smtphost>
> <smtpport>25</smtpport>
> <from>miguel.valencia@juntadeandalucia.es</from>
> <to>miguel.valencia@juntadeandalucia.es</to>
> <subject>españa camión</subject>
> <body mime-type="text/plain">
>           Nombre del remitente: prueba, Miguel<br />
>           Mensaje:Prueba de mensaje en españa, camión.</body>
> 
> <reply-to>miguel.valencia@juntadeandalucia.es</reply-to>
> </sendmail>
> </document>
> 

Did you use a <map:serialize type="utf8-xml"/>? Can you attach the xml
to exclude problems that the mail client may produce? The underlying
server has the locale UTF8_ES?

> It's seems that all text lose encoding, but I have checked that emails have
> subject correct and bad encoding on body field.
> I load a test email:
> http://old.nabble.com/file/p29889393/test-email.txt test-email.txt 

Hmm, let us do some tests: 
1) create a new match where you use the above input but 
a) use #&266; for all latin characters
b) write the "españa" yourself 
where you save the document and store them on the file system.
2) use <body src="cocoon://yourBody.xml"> and <body
src="cocoon://yourBody.xml" mime-type="text/plain"> and create a match
for the body.

What is happening?

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
Hi

  I did what you tell me, and the result is:
<document>
<sendmail>
<smtphost>mail-int.andaluciajunta.es</smtphost>
<smtpport>25</smtpport>
<from>miguel.valencia@juntadeandalucia.es</from>
<to>miguel.valencia@juntadeandalucia.es</to>
<subject>españa camión</subject>
<body mime-type="text/plain">
          Nombre del remitente: prueba, Miguel<br />
          Mensaje:Prueba de mensaje en españa, camión.</body>

<reply-to>miguel.valencia@juntadeandalucia.es</reply-to>
</sendmail>
</document>

It's seems that all text lose encoding, but I have checked that emails have
subject correct and bad encoding on body field.
I load a test email:
http://old.nabble.com/file/p29889393/test-email.txt test-email.txt 
-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29889393.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by Thorsten Scherler <sc...@gmail.com>.
On Tue, 2010-10-05 at 05:26 -0700, mvalencia wrote:
> Hi all
> 
>   I have a problem using the code of:
> org.apache.cocoon.mail.transformation.SendMailTransformer, when I send an
> email, target user always receive the field body with strange characters, so
> seemd bad encoding, and is curious only the field body, the subject is ok.
> 
> I work with encoding UTF-8, and I check Tomcat configuration is good:
>  * parameter: URIEncoding="UTF-8"
>  * SetCharacterEncoding = UTF-8
>  * container-encoding = utf-8
>  *  form-encoding = utf-8
> 
> I check encoding os serializers on Cocoon, too:
> <map:serializer name="xml-utf8" mime-type="text/xml"
> src="org.apache.cocoon.serialization.XMLSerializer">
>   <encoding>UTF-8</encoding>
> </map:serializer >
> <map:serializer name="xhtml"
> src="org.apache.cocoon.serialization.XMLSerializer">
>           <doctype-public>-//W3C//DTD XHTML 1.0 Strict//EN</doctype-public>
>          
> <doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</doctype-system>
>           <encoding>UTF-8</encoding>
> </map:serializer>
> 
> I only see that There is any problem on AbstractSAXTransformer to recovery
> data from textarea field on HTML, because is the diference between field
> subject and body.

hmm, can you send us the xml that comes in just BEFORE the
SendMailTransformer? Just add <map:serializer/> BEFORE and see whether
there is the correct encoding in the body.

salu2

> 
> Thank you

-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


I really appreciate if somebody would help me with Cocoon 2.2/Fop/Batik

Posted by Fawzib Rojas <f_...@spectron-msim.com>.
  I've posted twice about this and got no response.

My problem:

I'm moving from cocoon 2.1 to 2.2 (haven't done it yet because I knew 
maven would be a PITA and it didn't dissapoint). After a lot of hair 
pulling I finally compiled my webapp + blocks for cocoon 2.2 and was 
able to deploy on geronimo. The problem now is that cocoon-fop-impl will 
not work with embedded SVG. It uses fop-0.20.4 which wants to use batik 
1.6 and those 2 are incompatible. After looking around in a lot of posts 
found out about cocoon-fop-ng-impl, unfortunately it cant be found on 
maven (why?). Found a post that linked to the source, after more hair 
pulling got it working cocoon-fop-ng-impl+fop-1.0+batik 1.7.

I thought I was done but no. Now the SVG serializer stopped working. So 
I'll try and make a batik-ng. I did and now batik is giving me errors I 
was getting NullPointerException in SAXDocumentFactory.java at:

public void startElement(String uri,String localName,String 
rawName,Attributes attributes) throws SAXException {
         // Check If we should halt early.
         if (HaltingThread.hasBeenHalted()) {
             throw new SAXException(new InterruptedIOException());
         }
         if (inProlog) {
             // for some reason parser is null here
             inProlog = false;
             try {
                 isStandalone = parser.getFeature
                     ("http://xml.org/sax/features/is-standalone");
             } catch (SAXNotRecognizedException ex) {
             }
             try {
                 xmlVersion = (String) parser.getProperty
                     ("http://xml.org/sax/properties/document-xml-version");
             } catch (SAXNotRecognizedException ex) {
             }
         }
.....
}

I moved both trys to where the parser is created since that code just 
saves the values so *I think* it makes no difference. Now I get another 
error:

java.lang.ClassCastException: org.apache.batik.dom.GenericElement cannot 
be cast to org.w3c.dom.svg.SVGSVGElement

after another search found a post talking about 
DOMUtilities.deepCloneDocument saying it would convert dom to Batik's 
own dom. It gives me the same error, so I'm stuck. I would really 
appreciate any help on this.

<rant>
It was much easier to work with Cocoon 2.1, just add jars to build path 
in eclipse and that was it. I find maven to be an obstacle, most of the 
time I'm fighting it to get something done. When the dust settles I 
still end up downloading and creating my own things because what I need 
either outdated (cocoon-fop-impl), non-existent even though it was 
created a long time ago (cocoon-fop-ng-impl) or just wrongly configured 
(cocoon-fop-impl again).

Also, why when a new version of a library is created most of the time 
compatibility is just ignored (and I see this a lot with java)? Why not 
add a simple class that uses the old interfaces so you can move up to 
new versions without problems.
</rant>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
hi everybody

  I have found one solution to my problem. I change attribute "mime-type" of
email:body on xsl page from transform cocoon to value:"text/xml" and now the
email arrive well. Exactly:
old = <email:body mime-type="text/plain">
new = <email:body mime-type="text/xml">

In the code of SendMailTransformer.java I see that when mime-type is
text/plain body set with MimeMessage variable and when mime-type is another
value the body field set with MimeBodyPart variable.
It seem that MimeMessage variable does not manage encoding correctly.

Anyway for me the matter is fixed.

Thanks all.

-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29950964.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem encoding using SendMailTransformer

Posted by mvalencia <mi...@juntadeandalucia.es>.
Hi Charles 

I have configured the parameter URIEncoding to UTF-8, even I used the
parameter useBodyEncodingForURI but I go on with the same problem.


-- 
View this message in context: http://old.nabble.com/problem-encoding-using-SendMailTransformer-tp29886850p29931532.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org