This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes downloading csv within Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "downloading csv within Struts" Watch "downloading csv within Struts" New topic
Author

downloading csv within Struts

damien malone
Ranch Hand

Joined: May 06, 2003
Posts: 35
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
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: downloading csv within Struts
 
Similar Threads
Progress Bar Issue in JSP
convert data in JSP page to .csv format
How to download csv file
Adding/changing java classes on eclipse project
is it possible to convert reports in jsp to pdf format?