• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mime type tags in the deployment descriptor

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I want to ask about what are the mime-mapping in the deployment descriptor for??
What effect will they have on servlets ??
 
Imran Vohra
Ranch Hand
Posts: 77
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really good question....
now I am thinking..why should I have not asked this question?

Please let us know the answer.

Imran
 
Dirk Lombard
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand it you use the mime-mapping to set the contentType when you send a file to the browser. Say for instance you have a file that was created with a *.gif extention you send in either the file name or the .extention and the mime-type that was defined in your web.xml is returned as the content type that is returned to the browser. So for a certain extension you will always return the right content type. So then you browser will know how to render the data it has received.

// set the content type of the image data to be sent to the browser
response.setContentType(getServletConfig().getServletContext().getMimeType(file.toString()));
or response.setContentType(getServletConfig().getServletContext().getMimeType(".gif"));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic