1

I have this piece of code:

public void generateXML(DynamicForm form) {
        Document doc = XMLParser.createDocument();

        Element root = doc.createElement("root");
        doc.appendChild(root);

        Element node1 = doc.createElement("node1");
        node1.setAttribute("attribute","test");
        node1.appendChild(doc.createTextNode("my value"));
        doc.appendChild(node1);

        Element node2 = doc.createElement("node2");
        node2.setAttribute("attribute","anothertest");
        doc.appendChild(node2);
        System.out.println(doc.toString());
    }

How do I send this document to the client for download without storing it in a directory?

RAS
  • 8,100
  • 16
  • 64
  • 86
Crowlix
  • 1,269
  • 9
  • 19

2 Answers2

3

It really depends on how you wish to process it on client side.

If you wish the file downloaded popup to appear for user then follow How can a user download a file in client side (Google Web Toolkit)

If you wish to process the xml file download to display it some chart/etc then use request builder concepts with gwt xml processing.

Reference 1 - https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideHttpRequests
Reference 2 - https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasics#DevGuideXML
Reference 3 - https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsXML
Community
  • 1
  • 1
appbootup
  • 9,537
  • 3
  • 33
  • 65
1

Hard to say "NO".But its true.

You cannot do it on client side itself.Gwt(Javascript) does'nt have permission to write the content into user drives.

You have to make a request.(ex:FileDownLoadServlet).

Anyways you have to make a request to server.

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307