X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=server%2Fcom%2Fcompany%2Fhttpget.java;h=fa3b43130754c3c07eea00e0c589440cd4e34a7d;hb=HEAD;hp=079cc019d6e9d3ddca729145608eb30a91e137ce;hpb=bd7a266f1a37cb373614b8fa3d0c1e832c4b82e3;p=logicplayer.git diff --git a/server/com/company/httpget.java b/server/com/company/httpget.java index 079cc01..fa3b431 100644 --- a/server/com/company/httpget.java +++ b/server/com/company/httpget.java @@ -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 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(); } }