Login Register

Upload a file from a form to a servlet using dojo

Hi everyone!.

First of all, sorry about my english :).

I really need your help. I'm deeply stuck doing a proyect, and I can't see the light at the end of de tunnel.

That's my problem:

I need to upload a XML file from the client to the server without refreshing the page. I have a servlet in the server side to manage this file, using the FileUpload class from Apache. Everything is j2ee, servlets, jsp... and of course, dojo.

This file is introduced in a form. I try to upload it in that way, I change the code in a million different ways, but I can't fix the problem. Here's a part from the code:

Here's the scripts:

dojo.require("dojo.io.*");
 
    function submitCSSTML() {
   
      var params = Object();
      params.method = "POST";
      params.url = "servlets/personalTest";
      params.formNode = document.getElementById("personaltestform");
   
      dojo.io.bind(params);
       
    }
   
    function personalTest() {
   
        var XHR = getXMLHttpRequest();
        
    }

And here's the form:

<form name="personaltestform" action="#" method="POST" enctype="multipart/form-data">
           
             <label for="HTML">Documento HTML: </label>
             <input type="file" name="HTML" id="HTML" accept="text/plain"/>
           
           
             <label for="CSS">Documento CSS: </label>
             <input type="file" name="CSS" id="CSS" accept="text/plain"/>
           
           
             <label for="CSSTML">Documento CSSTML: </label>
             <input type="file" name="CSSTML" id="CSSTML" accept="text/plain" onchange="javascript:submitCSSTML()"/>
           
           <p id="formsubmit">
             <input type="submit" value="Test"></input>
           
         </form>

Anyone can help me?, any suggestion, idea... I'll be very thankful