It is the client who resquested so client know what type of data is coming.
then why is server again telling the same thing??
Its not the case always. The client only sends requests for a resource and the server decides what to serve back.
For instance consider a online form filling/billing a application. The moment you fill in the details and click Submit, a PDF version of the completed form or a receipt is sent back to you.
The content type also needs to be set so that the browser knows what to do with the content. Browsers like Firefox can be customized to deal with particular content types like open the file with an associated application or save it ,etc.
Setting the content types helps the browser with this also.
It gets a writer to the output stream of the response object, using which data can be written to the response.
Hope this helps
[ November 07, 2008: Message edited by: Amit Ghorpade ]