A question about a program given in Head First Servlets and JSP book

I'm learning servlets and JSP from "Head First Servlets and JSP" .In chapter 4 I came across an example which illustrate use of output stream by simply downloading a (jar) file .

I tried and understood the concept but what surprised me is that while downloading It didn't recognize the format(file extension .jar) instead of that it displays the name which is given in url-pattern is displaying (****.do)

This what that program does :
Simply getting the input stream of that jar file and writing it to the response's output stream

Whenever you do a response.setHeader, you are sending some instruction to the browser (which initiated the request). In this case with "Content-Disposition" you are advising the browser how to handle the content being streamed to it.

Ulf Dittmer's code says that the browser should treat the response body as an attachment and that it's name to be shown in the File Download dialog is "myFooBar.jar"

Hope this helps!

karthick Soundararaj
Greenhorn

Joined: Mar 09, 2009
Posts: 26

posted May 09, 2009 19:29:51

0

hareendran dileep wrote:Karthick,

Whenever you do a response.setHeader, you are sending some instruction to the browser (which initiated the request). In this case with "Content-Disposition" you are advising the browser how to handle the content being streamed to it.

Ulf Dittmer's code says that the browser should treat the response body as an attachment and that it's name to be shown in the File Download dialog is "myFooBar.jar"

Hope this helps!

Thank you.. Now , how do you find these kind of values and header names.. Yes, googling can give us 100's of pages. But still, how does someone himself find the header needed for a particular action?