• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Mime type tags in the deployment descriptor

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"));
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic