• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Downloading a file?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm starting my first project with struts and java, everything is going mostly Ok, but I'm having a problem with one of the requirements. A users submits criteria for a query and the result set and a graph are returned and displayed in a jsp so far no problem. What I need to do is allow the user to download the result set as a textfile or maybe as an excel file any thoughts on how to do this. Thanks in advance.
cheers
Randy
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Randy

This is what I do in my application to export data to user in csv\xls file.

Here is the code snippet from my action class:-

String filename = (String)session.getAttribute("Export_FileName");
response.setHeader("Content-disposition","attachment;filename="+filename);
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println(strExportData);
pw.flush();
pw.close();
return mapping.findForward("success");

//Tilak
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic