aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem with Jar download code in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem with Jar download code in servlet" Watch "Problem with Jar download code in servlet" New topic
Author

Problem with Jar download code in servlet

Thirugnanam Saravanan
Ranch Hand

Joined: Dec 13, 2007
Posts: 81
Hi All,

I have tried this code from Head First book ( Chapter 4 ) to implement the jar download functionality in servlets. The code is working fine, but while downloading the file,it is not getting downloaded as jar file( with .jar extension). Instead it is getting downloaded as a file with unknown filetype. What's wrong with this code? What should I do to implement my code in such a way that, when i download, it should be downloaded as a .jar file? Any Ideas?


[ November 18, 2008: Message edited by: Thirugnanam Saravanan ]

Saravanan
SCJP 5.0(98%), SCWCD 5.0 (100%), OCA
cesar valencia
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
Originally posted by Thirugnanam Saravanan:
Instead it is getting downloaded as a file with unknown filetype. What's wrong with this code? What should I do to implement my code in such a way that, when i download, it should be downloaded as a .jar file? Any Ideas?


set the "content-disposition" header, like this:



just replace that with the filename and you're set.


scjp5, scwcd5
Thirugnanam Saravanan
Ranch Hand

Joined: Dec 13, 2007
Posts: 81
Thanks . Now it works
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi, Can you please let me know why do we need [B] and [/B> here


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1524
    
  22

Hi, Can you please let me know why do we need [B] and [/B> here

That is a small mistake: they don't need to be there

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Jar download code in servlet
 
Similar Threads
Doubt in HTTPServletResponse
Read operation over URLConnection is stuck!
code for file download
download file using OutputStream from Servlets
problem running the download JAR application