You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anjishnu Bandyopadhyay <an...@infosys.com> on 2006/03/21 11:51:25 UTC

Problem with character encoding.

Hi all,



I am generating a MS Word document through a JSP, by setting the JSP's
content type as "application/msword;".

The ".doc" that is generated contains accentuated French characters
(special French characters).



I use Websphere (WSAD) to develop the code, but use Tomcat server for
deployment & final testing.

In WSAD, the ".doc" file that is generated properly displays the special
characters. But, in Tomcat, these characters are broken (distorted).



The code snippet (in JSP) is as follows:

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

<%

      String fileName = "abc.doc";

      response.setContentType("application/msword");

      response.setLocale(java.util.Locale.FRENCH);

      response.setHeader("Content-Disposition","attachment;filename="+
fileName);

%>



Can anyone give me some pointer, regarding the problem might be? Am I
missing out something?



Thanks for your time.



With best regards,

Anjishnu.





**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Re: Problem with character encoding.

Posted by Antonio Petrelli <br...@tariffenet.it>.
Anjishnu Bandyopadhyay ha scritto:
> Hi all,
>
> I am generating a MS Word document through a JSP, by setting the JSP's
> content type as "application/msword;".
>   

Are you using a particular library to generate the file? Anyway 
generating an MS Word file through JSP seems odd to me...

> The ".doc" that is generated contains accentuated French characters
> (special French characters).
> ...
>
> In WSAD, the ".doc" file that is generated properly displays the special
> characters. But, in Tomcat, these characters are broken (distorted).
>   

Maybe I am missing something. Does WSAD have something native that 
handles MS Word files? Because Tomcat doesn't!
Anyway, the character set (UTF-8) has nothing to do with the final 
generated file (for the browser it should be a binary file, that must be 
handled by a plugin or an external application).
Ciao
Antonio

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


Re: Problem with character encoding.

Posted by Dave Newton <ne...@pingsite.com>.
Anjishnu Bandyopadhyay wrote:
> I am generating a MS Word document through a JSP, by setting the JSP's
> content type as "application/msword;".
>   

I really don't understand why you persist in thinking that _calling_
something a Word document _makes_ it a Word document. As I have stated
several times a Word document is a _binary_file_format_.

What are you using to generate the Word document? If you're just
outputting an HTML template (e.g. a standard JSP template) you are NOT
generating a Word document. If you are using a particular library to
properly generate a Word document you'll probably want to ask on a list
for that library.

Dave



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


Re: Problem with character encoding.

Posted by Dan Jas <dj...@cinci.rr.com>.
Are you using WSAD on Windows and Tomcat on Unix/Linux?


----- Original Message ----- 
From: "Anjishnu Bandyopadhyay" <an...@infosys.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, March 21, 2006 5:51 AM
Subject: Problem with character encoding.



Hi all,



I am generating a MS Word document through a JSP, by setting the JSP's
content type as "application/msword;".

The ".doc" that is generated contains accentuated French characters
(special French characters).



I use Websphere (WSAD) to develop the code, but use Tomcat server for
deployment & final testing.

In WSAD, the ".doc" file that is generated properly displays the special
characters. But, in Tomcat, these characters are broken (distorted).



The code snippet (in JSP) is as follows:

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

<%

      String fileName = "abc.doc";

      response.setContentType("application/msword");

      response.setLocale(java.util.Locale.FRENCH);

      response.setHeader("Content-Disposition","attachment;filename="+
fileName);

%>



Can anyone give me some pointer, regarding the problem might be? Am I
missing out something?



Thanks for your time.



With best regards,

Anjishnu.





**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, 
please notify the sender by e-mail and delete the original message. Further, 
you are not to copy, disclose, or distribute this e-mail or its contents to 
any other person and any such actions are unlawful. This e-mail may contain 
viruses. Infosys has taken every reasonable precaution to minimize this 
risk, but is not liable for any damage you may sustain as a result of any 
virus in this e-mail. You should carry out your own virus checks before 
opening the e-mail or attachment. Infosys reserves the right to monitor and 
review the content of all messages sent to or from this e-mail address. 
Messages sent to or from this e-mail address may be stored on the Infosys 
e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS*** 


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