File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Priya Gowda
Greenhorn
Posts: 2
Eclipse IDE Google Web Toolkit MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1776
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - is SimpleValue your custom class or it's present in some other jar. I am facing compilation issues.
 
Priya Gowda
Greenhorn
Posts: 2
Eclipse IDE Google Web Toolkit MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47231
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic