%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.io.*,java.util.*,java.awt.image.*,javax.imageio.*,javax.xml.bind.DatatypeConverter" %>
<%!
void writeImageDataToFile(File image_file, String svg_data)
{
if (svg_data == null) {
// Some fake data (a small arrow icon) useful for testing purposes when svg_data is not supplied in the URL
svg_data = "";
}
try {
//FileOutputStream fos = new FileOutputStream(image_file);
BufferedWriter bw = new BufferedWriter(new FileWriter(image_file));
//bw.write("");
bw.write(svg_data);
//bw.write("");
bw.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
%>
<%
String doc_base = getServletContext().getRealPath("/");
File render_dir = new File(doc_base,"render-3d");
File render_images_dir = new File(render_dir,"images");
//File flag_file = new File(render_images_dir,"flag.svg");
String svg_data = request.getParameter("svgData");
String svg_filename = request.getParameter("svgFilename");
if (svg_filename == null) {
svg_filename = "flag.svg";
}
File full_svg_file = new File(render_images_dir,svg_filename);
writeImageDataToFile(full_svg_file,svg_data);
out.println("");
%>