File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Doubt in HTTPServletResponse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Storm Applied this week in the Other Open Source APIs forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubt in HTTPServletResponse" Watch "Doubt in HTTPServletResponse" New topic

Doubt in HTTPServletResponse

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 ]

SCJP 5.0(98%), SCWCD 5.0 (100%), OCA
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Try adding this to the code before writing the response to output stream.

[ November 18, 2008: Message edited by: Amol Nayak ]
Thirugnanam Saravanan
Ranch Hand

Joined: Dec 13, 2007
Posts: 81
Now it is working fine as per my expectation. Thank you so much for the reply.
I agree. Here's the link:
subject: Doubt in HTTPServletResponse