I'm generating a .docx file server-side. I have it saved to a tmp directory, as follows:
docx.createDocx(System.getProperty("java.io.tmpdir") + "/example_title");
(I can confirm that this indeed works, the file is stored in /tmp/tomcat6-tmp/
And I want the user to be able to download the created file. I have tried the following:
out.println("<a href = '"+System.getProperty("java.io.tmpdir") + "/example_title.docx"+"'>Here ya go!</a>");
But that does not work. It directs me to http://localhost:8080/tmp/tomcat6-tmp/example_title.docx . This is obviously the wrong way to do this, but how does one create files on the server for the user to download using Tomcat?
Thank you, Dara
EDIT: Got it, for anyone that's interested:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("application/msword");
    response.setHeader("Content-Disposition", "attachment; filename=\"consolidatedReport.docx\"");
    // Load the template.
    // Java 5 users will have to use RhinoFileTemplate instead
    CreateDocx docx = new CreateDocx("docx");
    String text = "Lorem ipsum dolor sit amet.";
    HashMap paramsTitle = new HashMap();
    paramsTitle.put("val", "1");
    paramsTitle.put("u", "single");
    paramsTitle.put("sz", "22");
    paramsTitle.put("font", "Blackadder ITC");
    docx.addTitle(text, paramsTitle);
    docx.createDocx(System.getProperty("java.io.tmpdir") + "/example_title");
    FileInputStream a = new FileInputStream(System.getProperty("java.io.tmpdir") + "/example_title.docx");
    while(a.available() > 0)
      response.getWriter().append((char)a.read());
}
