my dog learned polymorphism*
The moose likes Struts and the fly likes Download link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Download link" Watch "Download link" New topic

Download link

kriegerd Salas

Joined: Aug 01, 2005
Posts: 8

I want to create a link to download a file. I'm using a servlet for this, but I wanted to know if there is a way to do it with struts.

Thanx a lot
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can create an Action that will send data to the outputStream of the HttpServletResponse object. There is an example of this in the struts-examples.war file that comes with the V1.2 download. Check out the class org.apache.struts.webapp.exercise.ImageAction.

Consultant, Sima Solutions
kriegerd Salas

Joined: Aug 01, 2005
Posts: 8
Thanx for the quick answer, I'll check it out.
kriegerd Salas

Joined: Aug 01, 2005
Posts: 8
Hi.. I encountered this problem: java.lang.IllegalStateException: Response is already committed.

I used part of the code in the ImageAction example, and set the content type to "application/octet-stream". I want the browser to open the save dialog after clicking on the link, but struts has already used the response. So, how can I do this in struts?
I agree. Here's the link:
subject: Download link
Similar Threads
Need upload programme through FTP
Getting part 2 ?
From Where can i download java 5/6 API Documentation?
how can i download j2ee api
Problem in Downloading PDF File using JSP