I got this servlet which creates JSON data and I want to pass this data on to a jsp page which is supposed to display the data via the InfoVis toolkit.
servlet.java
You don't have to drop the JSON as a string - it's valid JavaScript syntax:
When that's rendered by JSP, the end result — the HTML sent to the browser — will be something like:
Now the only thing you may want to do is HTML encode the JSON, since you're dropping it as an HTML attribute value:
Then your "init" function can expect a ready-to-use JavaScript object, with no need to call a JSON parser at all.