Figured out my answer !!! I simply have to give the control to a servlet without rewriting the URL. The portlet does not need to be aware of the fact that a file is being downloaded. Just transfer the control to a servlet, and it is done.

There is a good discussion on this ---

http://mail-archives.apache.org/mod_mbox/portals-pluto-user/200406.mbox/[EMAIL 
PROTECTED]


Hope it helps someone ;)

Thanks,
Amit

----Original Message Follows----
From: "Shah Amit" <[EMAIL PROTECTED]>
Reply-To: "Jetspeed Users List" <jetspeed-user@jakarta.apache.org>
To: jetspeed-user@jakarta.apache.org
Subject: J2 - Zip File Download
Date: Mon, 18 Apr 2005 13:28:55 -0400

Hi all,

I need to download a zip file from the server to client browser. I have a servlet which does this --

           FileInputStream fis = new FileInputStream(uFile);
           PrintWriter pw = response.getWriter();
           int c = -1;
           //             Loop to read and write bytes.
           while ((c = fis.read()) != -1) {
               pw.print((char) c);
           }
           //             Close output and input resources.
           fis.close();
           pw.flush();


Here is the servlet mapping from web.xml --

 <servlet-mapping>
   <servlet-name>UploadServlet</servlet-name>
   <url-pattern>/servlet/uploadServlet</url-pattern>
 </servlet-mapping>


And here is what I wrote in one of my jsp's --
<html:link href="/servlet/uploadServlet?fileName=c:\\temp\\test.zip" title="Download">Download</html:link>



When I click on the link, the whole setup does work. The only thing is, instead of giving me a download window where I can "save as" the file, it simply writes the entire file in the portlet itself so I see a bunch of garbage text in my portlet.


Please please I really need help with this :-(

Thanks,
Amit



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to