source: other-projects/nz-flag-design/trunk/similarity-2d/save-json-data.jsp@ 29968

Last change on this file since 29968 was 29788, checked in by davidb, 9 years ago

Changes to support storing on the server side of the HSV histogram calculations

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1<%@ page contentType="text/html; charset=UTF-8" %>
2<!DOCTYPE html>
3<html>
4 <head>
5 </head>
6
7 <body>
8
9 <div style="display: none;">
10
11 <script>
12 // Set up a fallback position in case this page is accessed outside of a JSP context
13 // (i.e., the JSP blocks aren't executed)
14 var message = "Failed to execute JSP code blocks";
15 var exit_val = 404; // not currently used
16
17 </script>
18
19 <%@ page import="java.io.*,java.util.*,javax.xml.bind.DatatypeConverter" %>
20
21 <%!
22
23 void writeDataToFile(File json_file, String json_data)
24 {
25 try {
26 FileWriter fw = new FileWriter(json_file);
27 BufferedWriter bfw = new BufferedWriter(fw);
28 bfw.write(json_data);
29 bfw.close();
30 }
31 catch (Exception e) {
32 e.printStackTrace();
33 }
34 }
35 %>
36
37 <%
38 String doc_base = getServletContext().getRealPath("/");
39 File similarity_dir = new File(doc_base,"similarity-2d");
40 File similarity_data_dir = new File(similarity_dir,"json-data");
41
42 String json_data = request.getParameter("jsonData");
43 String json_filename = request.getParameter("jsonFilename");
44
45 if (json_filename == null) {
46 json_filename = "data.json";
47 }
48 File full_json_file = new File(similarity_data_dir,json_filename);
49
50
51 writeDataToFile(full_json_file,json_data);
52
53 out.println("<script>");
54 out.println("message = \"Image File Saved: &lt;docBase&gt;/similarity-2d/json-data/" + json_filename + "\";");
55 out.println("</script>");
56
57 %>
58
59 </div>
60
61 <script>
62
63 document.write("<div>" + message + "</div>\n");
64
65 </script>
66
67 </body>
68
69</html>
Note: See TracBrowser for help on using the repository browser.