question: private String buildJavaScriptData ( String event , String msg ) { String b64EncodedMsg = "Error!" ; try { if ( msg != null ) { b64EncodedMsg = Base64 . encodeBytes ( msg . getBytes ( UTF8_CHARSET ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } String _d = "javascript:WebSocket." + event + "(" + "{" + "\"_target\":\"" + id + "\"," + "\"_data\":'" + b64EncodedMsg + "'" + "}" + ")" ; return _d ; }
target:  Builds text for javascript engine to invoke proper event method with proper data.