• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet containers and static resources

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ranchers,

I cannot find much regarding specification for serving static resoruces (images, etc) from Servlet Containers.
2.4 Servlet spec implies that this is done via "Image conversion filters" (page 50)...

it also mentions this:

<filter>
<filter-name>Image Filter</filter-name>
<filter-class>com.acme.ImageServlet</filter-class>
</filter>

Does this mean all static content is served using a filter? I got a blank installation of Tomcat and could not find anything image-related other than:
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>

what am I missing? I decided to post this into Servlet forum because it seems to be a matter of standards rather than Tomcat... Thanks!
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you put your images right inside your web application just like you would put a JSP, web clients can simply access them directly without any filters or mapped servlets.

For example, if your webapp is named "test.war", and you put "test.gif" in the root directory of the WAR, the image can be retrieved directly from http://localhost:8080/test/test.gif.
 
Alexey Gor
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response, but I want to actually understand how this works. i.e. how does Servlet Spec specify static content to be handleled and how it fits within the whole scheme of mapping servlets to URIs.

The part I'm most curious about is this. If static content is served by a servlet/filter, then why cannot i find the mapping for it? If static content is served by some other means, why cannot i find that in the spec?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat handles this with the DefaultServlet.
The mapping for it is in the web.xml file in tomcat/conf.

I'm most other containers deal with this in a similar way.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic