• 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 csv within Struts

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Apologies if this is not the correct forum. I have written a servlet that generates a csv file. This all works fine, but I now want to integrate this servlet into a struts web app. I have the following lines at the top of my servlet
String filename = "export.csv";
response.setContentType("application/unknown");
response.setHeader("Content-Disposition", "attachment;filename=\""+filename+"\"");

I have also tried re-writting as a jsp. and placing the setheader into the action class.
However what ever I try, when I try and access the page, the servlet and action class are run (I have system outs that are displayed) but the browser then pops up a message dialog saying unable to locate the web page I am trying to download.
Any ideas??
Thanks
Damien Malone
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just configure your servlet in your web.xml on a different path than struts. Also struts uses a servlet as controller when you check your
web.xml. Normally it is mapped to /do/ or *.do.
So maybe a good solution would be to create the following entry:

Then you can access your Servlet with
http://yourserver/yourapp/generator/
hope that helped
 
I found a beautiful pie. And a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic