protected void doWrite(HttpServletRequest request,HttpServletResponse response,String tunnelUUID) throws GuacamoleException {
  GuacamoleTunnel tunnel=getTunnel(tunnelUUID);
  response.setContentType("application/octet-stream");
  response.setHeader("Cache-Control","no-cache");
  response.setContentLength(0);
  try {
    GuacamoleWriter writer=tunnel.acquireWriter();
    Reader input=new InputStreamReader(request.getInputStream(),"UTF-8");
    try {
      int length;
      char[] buffer=new char[8192];
      while (tunnel.isOpen() && (length=input.read(buffer,0,buffer.length)) != -1)       writer.write(buffer,0,length);
    }
  finally {
      input.close();
    }
  }
 catch (  GuacamoleConnectionClosedException e) {
    logger.debug("Connection to guacd closed.",e);
  }
catch (  IOException e) {
    deregisterTunnel(tunnel);
    tunnel.close();
    throw new GuacamoleServerException("I/O Error sending data to server: " + e.getMessage(),e);
  }
 finally {
    tunnel.releaseWriter();
  }
}

protected void doWrite ( HttpServletRequest request , HttpServletResponse response , String tunnelUUID ) throws GuacamoleException { GuacamoleTunnel tunnel = getTunnel ( tunnelUUID ) ; response . setContentType ( "application/octet-stream" ) ; response . setHeader ( "Cache-Control" , "no-cache" ) ; response . setContentLength ( 0 ) ; try { GuacamoleWriter writer = tunnel . acquireWriter ( ) ; Reader input = new InputStreamReader ( request . getInputStream ( ) , "UTF-8" ) ; try { int length ; char [ ] buffer = new char [ 8192 ] ; while ( tunnel . isOpen ( ) && ( length = input . read ( buffer , 0 , buffer . length ) ) != - 1 ) writer . write ( buffer , 0 , length ) ; } finally { input . close ( ) ; } } catch ( GuacamoleConnectionClosedException e ) { logger . debug ( "Connection to guacd closed." , e ) ; } catch ( IOException e ) { deregisterTunnel ( tunnel ) ; tunnel . close ( ) ; throw new GuacamoleServerException ( "I/O Error sending data to server: " + e . getMessage ( ) , e ) ; } finally { tunnel . releaseWriter ( ) ; } }
called whenever the javascript guacamole client makes a write request . this function should in general not be overridden , as it already contains a proper implementation of the write operation .
