permaculture playing cards*
The moose likes Java in General and the fly likes Velocity Template is not encoding charecter,instead throwing an error message. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Velocity Template is not encoding charecter,instead throwing an error message." Watch "Velocity Template is not encoding charecter,instead throwing an error message." New topic
Author

Velocity Template is not encoding charecter,instead throwing an error message.

Priya Gowda
Greenhorn

Joined: Oct 09, 2011
Posts: 2

Hi All,

I am using velocity template to send email(In chinese language).So using hexa decimal charecter in template.But am getting some lexical error.
Here i have shown both normal java code implementation and template implemnetation.

Here in the above normal java piece of code, \"\u8bf7\u6c42:\" will encode properly in to Chinese character.

But if I use same \"\u8bf7\u6c42:\" in velocity template(eml.vsl) using

$message.setSubject(\"\u8bf7\u6c42:\")

Note-message is an object of class EmailMsg

it is throwing java.lang.Exception: Error processing velocity script:
Lexical error: org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 59, column 11. Encountered: "\"" (34), after : "\\"

Can anyone let me know what could be the fix for it.

Thanks in Advance,
Priya Gowda.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Hi - is SimpleValue your custom class or it's present in some other jar. I am facing compilation issues.
Priya Gowda
Greenhorn

Joined: Oct 09, 2011
Posts: 2

Thanks for your response!


This works fine as i give the input(hex code) in simple java.

but i have problem in reading the same input from velocity template.i read the template from sample java code as below and template has that hexadecimal charecter.


after line number 5 it throws a lexical error mentioned in my query.
Thanks!

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Welcome to the Ranch

You will have to find out why the Template does not allow quote marks after that backslash. It is obviously something to do with the permitted types of text in Velocity.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Velocity Template is not encoding charecter,instead throwing an error message.
 
Similar Threads
Suppressing Applet alerts when using mail API
Issue while using Apache Velocity with servlets
Help executing velocity example
Velocity Templates with Servlets
Velocity Templates with Servlets