public void handle(HttpExchange exchange) {
            System.err.println("Connection established");
            /* Get the jar file and remove the leading slash */
            String requestedPlugin;
            requestedPlugin = exchange.getRequestURI()
                .toString().substring(1);

            File requestedFile = new File(directory + requestedPlugin);

            if(!requestedFile.canRead()) {
                /* If we can't access the file return 404 */
                try{
                    exchange.sendResponseHeaders(404, -1);    
                } catch(IOException ex) {
                    return;
                }

            } else {

                try{
                    exchange.sendResponseHeaders(200, 0);
                } catch(IOException ex) {
                    return;
                }

                BufferedOutputStream toClient;
                toClient = new BufferedOutputStream(
                    exchange.getResponseBody());

                BufferedInputStream fromFile;
                try{
                    fromFile = new BufferedInputStream(
                        new FileInputStream(requestedFile));
                } catch(IOException ex) {
                    System.err.println("PluginServer: Error opening file " +
                       requestedPlugin); 
                    return;
                }
                
                /* Send file */
                byte [] buffer = new byte[1024];
                try{
                    int read = fromFile.read(buffer);
                    while(read != -1) {
                        try{
                            toClient.write(buffer, 0, read);
                            read = fromFile.read(buffer);
                        } catch(IOException ex) {
                            return;
                        }
                    }
                } catch(IOException ex) {
                    System.err.println("PluginServer: Error reading file " +
                       requestedPlugin); 
                    return;
                }

                try{
                    toClient.close();
                    fromFile.close();
                } catch(IOException ex) {
                    return;
                }
            }
        }