In my opinion, that is always better way to create data by portlet (java) and only the visualization put to the jsp. I know that is not so elegant to create JSON with java, but you can use various frameworks for serialization
Jackson: https://github.com/FasterXML/jackson-databind/
XStream: http://x-stream.github.io/json-tutorial.html
or create plain JSON with org.json.*
http://json.org/java/
see too How to Create JSON Array in Java
you can also put the column names to java path.