]> matita.cs.unibo.it Git - logicplayer.git/blobdiff - server/com/company/httpget.java
New version
[logicplayer.git] / server / com / company / httpget.java
index 079cc019d6e9d3ddca729145608eb30a91e137ce..fa3b43130754c3c07eea00e0c589440cd4e34a7d 100644 (file)
@@ -33,44 +33,36 @@ public class httpget implements Runnable {
                        server.createContext("/test", new MyHandler());
                        server.setExecutor(null); // creates a default executor
                        server.start();
-               }catch (Exception e)
-               {
+               } catch (IOException e) {
                        e.printStackTrace();
                }
-    }
+       }
 
     static class MyHandler implements HttpHandler 
     {
         public void handle(HttpExchange t) throws IOException
         {
-                       
-            /*String response = "This is the response";
-            System.out.println("mannaggia santa");
-            t.sendResponseHeaders(200, response.length());
-            OutputStream os = t.getResponseBody();
-            os.write(response.getBytes());*/
                        URI req=t.getRequestURI();
             String query=req.getQuery();
             Map<String, String> result=splitQuery(query);
             String id=result.get("id");
-            //System.out.println(id);
             try
             {
-                               dbConnect request=new dbConnect();
-                               String returnQuery=request.dbQuery("3"+id);
+
+                               String returnQuery=global.request.dbQuery("3"+id);
                                t.sendResponseHeaders(200, returnQuery.length());
                                OutputStream os = t.getResponseBody();
                                os.write(returnQuery.getBytes());
                                os.close();
-                       }
-                       catch(SQLException e)
-                       {}
-                       catch(ClassNotFoundException c)
-                       {}
-                       catch(IllegalAccessException a)
-                       {}
-                       catch(InstantiationException i)
-                       {} catch (NoSuchAlgorithmException e) {
+                       } catch (ClassNotFoundException e) {
+                               e.printStackTrace();
+                       } catch (SQLException e) {
+                               e.printStackTrace();
+                       } catch (InstantiationException e) {
+                               e.printStackTrace();
+                       } catch (NoSuchAlgorithmException e) {
+                               e.printStackTrace();
+                       } catch (IllegalAccessException e) {
                                e.printStackTrace();
                        }
                }