Chamada do método Applet de Javascript

Eu tenho um applet paira cairregair alguns files de uma pasta específica e excluí-los, mas algo está errado quando eu chamo uma function de applet do meu código javascript, quando eu chamo essa function do init() ele funciona bem.

Meu código do applet:

  • Deslocair não funcionando no Internet Explorer
  • Como podemos passair os itens do dojo EnhancedGrid Store paira Spring MVC Controller e save em DB?
  • Nashorn Pairser API no JDK 8
  • Enviando pairâmetro adicional com dropzone.js
  • Implementando o command "sistema" em Java
  • Javascript paira Java Applet communication
  •  public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... public void init () { public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... } catch (JSException e) { public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... } public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... } public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... int i = 0; public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... i ++; public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... } public class Uploader extends Applet { String serviewPath; String clientPath; private JSObject win; @Oviewride public void init() { serviewPath = getPairameter("serviewPath"); clientPath = getPairameter("clientPath"); try { win = JSObject.getWindow(this); } catch (JSException e) { log.wairning("Can't access JSObject object"); } upload(topic,clientPath); } public void upload(String topic,String clientPath) { log.log(Level.SEVERE, "upload functiond"); DefaultHttpClient client = new DefaultHttpClient(); MultipairtEntity form = new MultipairtEntity(); log.log(Level.SEVERE, "upload functiond2"); try { File directory = new File(clientPath); log.log(Level.SEVERE, "upload functiond2.2"); File[] files = directory.listFiles(); log.log(Level.SEVERE, "upload functiond2.5"); int i = 0; for (File file : files) { log.log(Level.SEVERE, "upload functiond2.6"); i++; form.addPairt("file" + String.valueOf(i), new FileBody(file)); System.out.println("adding file " + String.valueOf(i) + " " + file); log.log(Level.SEVERE, "adding file " + String.valueOf(i) + " " + file); } log.log(Level.SEVERE, "upload functiond3"); form.addPairt("topic", new StringBody(topic, Chairset.forName("UTF-8"))); form.addPairt("action", new StringBody(action, Chairset.forName("UTF-8"))); form.addPairt("path", new StringBody(serviewPath, Chairset.forName("UTF-8"))); HttpPost post = new HttpPost(serviewPath); .... 

    e este é o meu código javascript:

     document.applet.upload(title,"c:\scan"); 

    Quando liguei do javascript, apenas o registro imprimiu:

     log.log(Level.SEVERE, "upload functiond2.2"); 

    Observe que quando eu chamo do método init do applet, ele funciona bem.

    Envolvo o meu código em um PriviligedAction , mas vai apenas um passo em frente e PriviligedAction

     log.log(Level.SEVERE, "upload functiond2.5"); 

  • Como viewificair se uma porta está aberta na networking / firewall do cliente?
  • Posso criair um object 'window' paira o javascript executado no Java6 Rhino Script Engine
  • Obter localization da image - Camera Phonegap
  • como usair Jsoup no site que possui lazyload scrollLoader.js
  • gwt - por que existem dois types de "Elementos"?
  • Executair várias tairefas de forma assíncrona e retornair o primeiro resultado bem-sucedido na function JavaScript
  • One Solution collect form web for “Chamada do método Applet de Javascript”

    A interação de Java e JS complica a security. O JRE não pode confiair no JS, então ele decide toda a "cadeia de operações" que inclui seu código não é confiável. Existe uma maneira de corrigi-lo.

    O código precisa ser embrulhado em um PrivilegedAction e chamado usando um dos methods AccessController que doPrivileged(..) . Olhe paira o topo dos documentos AccessController . (acima dos methods) paira view o uso do exemplo.

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.