File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Mail Content problem for Arabic & Hebrew language Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Mail Content problem for Arabic & Hebrew language" Watch "Mail Content problem for Arabic & Hebrew language" New topic
Author

Mail Content problem for Arabic & Hebrew language

Vinayak Sakhare
Greenhorn

Joined: Apr 06, 2009
Posts: 12

Hi,

I'm using JMS to send the mail.
When content are arabic or hebrew it shows as in the mail if mail sending code is called through JAVA.

Where as if I call the same code from JSP page & hard-code the arabic text in it, then it is shown in the mail properly.
I've tried setting content type as UTF-8,UTF-16,Windows-1256.Still same problem is there.

When mail is send through JSP page.It automatically gets converted to following text :



I don't know what the above characters are, but somehow gmail or any other mail client understands this format & it renders the text.
Why this happens ? Is there any solution through which I can convert my String into above format ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

So what's different? In one case the characters are hard-coded in source code, and in the other case... you didn't say. But that's your problem, anyway. In the other case you are doing something wrong. It's impossible to say what without knowing where the characters are coming from and how you are getting them.
Vinayak Sakhare
Greenhorn

Joined: Apr 06, 2009
Posts: 12

Paul Clapham wrote:So what's different? In one case the characters are hard-coded in source code, and in the other case... you didn't say. But that's your problem, anyway. In the other case you are doing something wrong. It's impossible to say what without knowing where the characters are coming from and how you are getting them.


Hi Paul,
Actually when I hard-code the content-text in JSP -> Eclipse do not allow me to save that text because of encoding problem.So I tried it saving from console using Linux command "vi". After doing this when I refresh my JSP page in eclipse.I got above text, which after executing the sendMail() function sets the proper content.

Thats my question,
Either I need to convert my Arabic text to the format which eclipse did in case of JSP or
Is there any other setting which I need to do while sending Arabic text using JMS ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

Vinayak Sakhare wrote:Actually when I hard-code the content-text in JSP -> Eclipse do not allow me to save that text because of encoding problem.


If you're going to be dealing with Arabic and Hebrew characters, then you should at least be encoding your JSPs and other source code in a proper encoding. That would be one which can represent those characters. UTF-8 would be one good choice, as would UTF-16. In Eclipse that means that you should change your project preferences to include a proper encoding.

As for your Java code, if you're going to send that data through JMS then choose a message type which supports characters properly. If your message payload is going to be encoded into bytes then you chose the wrong type.
Vinayak Sakhare
Greenhorn

Joined: Apr 06, 2009
Posts: 12

Paul,
May be you are misunderstanding the question.
I'm working in English language only.
The data which need to be send as a mail-content is stored in DB.
Let me explain you code wise :

In JAVA :

Result: contents of mail - > ???

Now same code In JSP:

Result: contents of mail -> hard coded text


I'm using MQ-Server to logged the mails send via JMS.
After checking log tables it is observed that, JSP page contents got converted into some other unreadable format (I've mentioned in first post)
whereas in case of JAVA file code the Arabic text got logged as a content.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

Vinayak Sakhare wrote:I'm working in English language only.


No, you aren't. Look at the title of your post to see why not.

And slowly you are telling us what is really going on. First we had the JMS story, now it turns out there is a database involved. So there are two steps: (1) Get data from the database, (2) sending the data via e-mail. You seem to have assumed without any evidence that step (1) is working correctly. Am I misunderstanding again? Have you actually tested your Java code which gets text from the database to check that it didn't damage the text?
Vinayak Sakhare
Greenhorn

Joined: Apr 06, 2009
Posts: 12

yes..step 1 is correct.Same data is there in db.
My question is that if I retrieve data from db & set in the java code written for sending mail then content gets as ??..
but same data is hard-coded in jsp then it is working fine..
Vinayak Sakhare
Greenhorn

Joined: Apr 06, 2009
Posts: 12

Vinayak Sakhare wrote:
Either I need to convert my Arabic text to the format which eclipse did in case of JSP or
Is there any other setting which I need to do while sending Arabic text using JMS ?


Found out the solution for the issue. :jumpingjoy:

While setting the content into mail I changed my text to ISO-8859-1 format, which eclipse did in case of JSP.



Now mail is getting send through JAVA code also. :thumbup:

Thanks Paul, for replaying quickly. :)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mail Content problem for Arabic & Hebrew language