Using Sun Java Studio Creator with SVG - Adding a JSP or HTML page
(Page 2 of 4 )
Highlight the Web Pages folder of the project, in this case DisplaySvg. From the File menu drop-down, choose New Item.... The New item window opens where you can add a Page, an Html file, a PageFragment, and so on.
You may also right click the Project and the drop-down and create the same items. Click next and you will provide a name for the file. In this case an AddSvg.jsp was added as shown. Similarly an HTML file named DSvg.html was also added (see the fourth picture down from here for the directory structure). Now we need to embed a SVG file in this JSP, for which we need to add a SVG file to the project.
Adding SVG content to the project
The SVG content can be added to a JSP page or an HTML file. In either case you need to bring the SVG file into your project.
For lack of documentation it is assumed that the SVG file is a resource file. Highlight the resources folder, which is a sub-folder of Web Pages, and right click. From the drop-down click on New as shown in the next picture.

This opens a menu where you can choose several items, but you cannot recognize any which could be an SVG file. Trying to add an Empty File..., then trying to fill it up with the SVG file contents, and then trying to save it with an SVG extension will not work because the Empty file does not allow renaming of the extension. Choose the File/Folder... hyperlink and click. This opens up the next window, New File, again. When you click on Resources you do not see an SVG option either, as you can see here.

The work around to bring the file into the project is as follows:
Highlight the resources folder, and from the File menu item click on Add Existing Item, which shows a drop-down. Here choose Other (all files)... and click.

This opens up the My Documents folder on your C: drive. Here you can locate your SVG file and click on Add. This adds the file to the Source Packages folder as shown in the next picture.

However, you cannot point a src reference to this folder when you embed the file in either HTML or a JSP page (the program throws an exception). You can however drag this file from the Sources Packages-->dispalySVG package to the resources folder. Two SVG files, circles.svg and Unicode.svg, which were added in this manner, are shown in the next picture.

Next: SVG files used in this tutorial >>
More Java Articles
More By Jayaram Krishnaswamy