EJS is a java code generator so you can either write your own java code or use available java library.
Please check out attached file for examples.