• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mail Content problem for Arabic & Hebrew language

 
Greenhorn
Posts: 12
Hibernate Postgres Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
Hibernate Postgres Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 12
Hibernate Postgres Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 12
Hibernate Postgres Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
Hibernate Postgres Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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. :)
 
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic