Issue
In my Spring MVC application, an svg-image is to be generated by controller "on-fly" and displayed in JSP page. Is there an elegant method to do this using Spring MVC capabilities without saving the svg-image as a file?
Solution
If it were me I would have an img
tag on my JSP page with a src
that points to a @Controller
that invokes the svg generator and returns the generated svg as a Spring Resource or as a ByteArrayInputStream (although the latter may risk OOMs).
Answered By - Paul Warren
Answer Checked By - Terry (JavaFixing Volunteer)