changeset 15:08262829d456

Added a configuration file (myapp.propoerties); reading the configuration file.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 03 Dec 2013 12:19:31 +0000
parents c7d52c9a8743
children 33d7bd3c0990
files webapp/WEB-INF/classes/myapp.properties webapp/WEB-INF/src/HumanEchoServlet.java
diffstat 2 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webapp/WEB-INF/classes/myapp.properties	Tue Dec 03 12:19:31 2013 +0000
@@ -0,0 +1,2 @@
+tmpdir=/tmp
+outdir=/tmp
\ No newline at end of file
--- a/webapp/WEB-INF/src/HumanEchoServlet.java	Fri Nov 29 17:08:12 2013 +0000
+++ b/webapp/WEB-INF/src/HumanEchoServlet.java	Tue Dec 03 12:19:31 2013 +0000
@@ -1,16 +1,20 @@
+
+import java.util.Properties;
+import java.io.IOException;
+
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletException;
 import javax.servlet.ServletConfig;
-import java.io.IOException;
-
-import uk.ac.soton.isvr.*;
 
 import com.mathworks.toolbox.javabuilder.MWJavaObjectRef;
 import com.mathworks.toolbox.javabuilder.MWNumericArray;
 import com.mathworks.toolbox.javabuilder.MWStructArray;
 import com.mathworks.toolbox.javabuilder.MWException;
+import com.mathworks.toolbox.javabuilder.internal.MCRConfiguration;
+
+import uk.ac.soton.isvr.*;
 
 public class HumanEchoServlet extends HttpServlet {
     private HumanEcho echo;
@@ -18,6 +22,19 @@
     public void init(ServletConfig config) throws ServletException {
         super.init(config);
 
+        // reading properties file
+        try {
+            Properties properties = new Properties();
+            properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("myapp.properties"));
+
+            //get the property value and print it out
+            System.out.println(properties.getProperty("tmpdir"));
+            System.out.println(properties.getProperty("outdir"));
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
         try {
             echo = new HumanEcho();
         }
@@ -56,7 +73,7 @@
 
             // the ofname should depend on the parameters
             StringBuilder sb = new StringBuilder();
-            sb.append("e_d");
+            sb.append("/tmp/e_d");
             sb.append(dist);
             sb.append(".wav");
             String outputfname = sb.toString();
@@ -70,12 +87,22 @@
             e.printStackTrace();
         }
 
- /*
+        System.out.println("MCRROOT: " + System.getenv("MCRROOT"));
+        System.out.println("PATH: " + System.getenv("PATH"));
+        System.out.println(MCRConfiguration.isInstalledMCR());
+
+
         StringBuffer buffer = new StringBuffer();
 
         buffer.append("<BR>");
         buffer.append("<BR>");
 
+        buffer.append("worked, ?");
+
+        buffer.append("<BR>");
+        buffer.append("<BR>");
+
+/*
         buffer.append("<TABLE >");
         for (double[] row : square)
         {