Mercurial > hg > human-echolocation-java-webapp
comparison src/HumanEchoServlet.java @ 42:65a26b38bf43
Some debug output, and work toward neatening the jsp &c
author | Chris Cannam |
---|---|
date | Tue, 25 Feb 2014 16:46:12 +0000 |
parents | 91ecbdda6f4a |
children | 84d02afe28e6 |
comparison
equal
deleted
inserted
replaced
40:65338d2507bc | 42:65a26b38bf43 |
---|---|
30 | 30 |
31 public class HumanEchoServlet extends HttpServlet { | 31 public class HumanEchoServlet extends HttpServlet { |
32 private HumanEcho echo; | 32 private HumanEcho echo; |
33 private static Logger logger = Logger.getLogger(HumanEchoServlet.class); | 33 private static Logger logger = Logger.getLogger(HumanEchoServlet.class); |
34 | 34 |
35 private String tempdir = ""; | |
36 private String wavdir = ""; | 35 private String wavdir = ""; |
37 | 36 |
38 public void init(ServletConfig config) throws ServletException { | 37 public void init(ServletConfig config) throws ServletException { |
39 super.init(config); | 38 super.init(config); |
40 | 39 |
41 // reading properties file | 40 System.err.println("In init"); |
41 | |
42 logger.error("java.library.path is " + | |
43 System.getProperty("java.library.path")); | |
44 | |
42 try { | 45 try { |
46 // Read directory properties | |
43 Properties properties = new Properties(); | 47 Properties properties = new Properties(); |
44 properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("myapp.properties")); | 48 properties.load |
49 (Thread.currentThread().getContextClassLoader(). | |
50 getResourceAsStream("myapp.properties")); | |
45 | 51 |
46 //get the property value and print it out | |
47 tempdir = properties.getProperty("tmpdir"); | |
48 wavdir = properties.getProperty("outdir"); | 52 wavdir = properties.getProperty("outdir"); |
53 | |
54 System.err.println("WAV file directory is " + wavdir); | |
49 | 55 |
50 } catch (IOException e) { | 56 } catch (IOException e) { |
51 e.printStackTrace(); | 57 e.printStackTrace(); |
52 } | 58 } |
53 | 59 |
54 try { | 60 try { |
61 // Test that we can construct one of the MATLAB objects | |
62 | |
63 long before = System.currentTimeMillis(); | |
55 echo = new HumanEcho(); | 64 echo = new HumanEcho(); |
56 } | 65 long after = System.currentTimeMillis(); |
57 catch(MWException e) { | 66 System.err.println("Created a HumanEcho object: it took " + (after - before) + " ms"); |
67 } catch (MWException e) { | |
58 e.printStackTrace(); | 68 e.printStackTrace(); |
59 } | 69 } |
60 } | 70 } |
61 | 71 |
62 public void destroy() { | 72 public void destroy() { |
63 super.destroy(); | 73 super.destroy(); |
64 | 74 |
65 if(echo!=null) { | 75 if (echo != null) { |
66 echo.dispose(); | 76 echo.dispose(); |
67 } | 77 } |
68 } | 78 } |
69 | 79 |
70 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | 80 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
73 int dist = Integer.parseInt(request.getParameter("dist")); | 83 int dist = Integer.parseInt(request.getParameter("dist")); |
74 | 84 |
75 logger.info("String azim is: " + request.getParameter("azim")); | 85 logger.info("String azim is: " + request.getParameter("azim")); |
76 Float azim = Float.parseFloat(request.getParameter("azim")); | 86 Float azim = Float.parseFloat(request.getParameter("azim")); |
77 | 87 |
78 | |
79 | |
80 | |
81 MWStructArray Input = null; | 88 MWStructArray Input = null; |
82 HumanEcho echo; | 89 HumanEcho echo; |
83 | 90 |
84 String outputfname = new String(); | 91 String outputfname = new String(); |
85 | 92 |
93 System.err.println("In doGet"); | |
94 | |
86 try { | 95 try { |
96 //!!! erch, shouldn't be creating a new one on each request as well as a global one | |
87 echo = new HumanEcho(); | 97 echo = new HumanEcho(); |
88 | 98 |
89 logger.error("We are logging!"); | 99 logger.error("We are logging!"); |
90 logger.warn(System.getProperty("catalina.base")); | 100 logger.warn(System.getProperty("catalina.base")); |
91 | 101 |
102 System.err.println("Done some logging"); | |
103 System.err.println(System.getProperty("catalina.base")); | |
92 | 104 |
93 // Matlab structure: | 105 // Matlab structure: |
94 // Input = struct('dist', 0.9, 'azim', 0, 'orient', 'horz', 'dirweight', 0.2, 'outputfname', 'foo.wav') | 106 // Input = struct('dist', 0.9, 'azim', 0, 'orient', 'horz', 'dirweight', 0.2, 'outputfname', 'foo.wav') |
95 | 107 |
96 String[] InputStructFields = {"dist", "azim", "orient", "dirweight", "outputfname"}; | 108 String[] InputStructFields = {"dist", "azim", "orient", "dirweight", "outputfname"}; |