JSP 2.0 SVG Example


This example uses JSP 2.0's new, simplified JSPX syntax to render a Scalable Vector Graphics (SVG) document. When you view the source, notice the lack of a <jsp:root> element! The text to be rendered can be modified by changing the value of the name parameter.

SVG has many potential uses, such as searchable images, or images customized with the name of your site's visitor (e.g. a "Susan's Store" tab image). JSPX is a natural fit for generating dynamic XML content such as SVG.

To execute this example, follow these steps:

  1. Download Apache Batik, or any other SVG viewer.
  2. Copy the following URL: http://localhost:8080/examples/jsp/jsp2/jspx/textRotate.jspx?name=JSPX
  3. Paste the URL into Batik's Location field and press Enter
  4. Customize by changing the name=JSPX parameter

The following is a screenshot of the resulting image, for those that don't have an SVG viewer: