aspose file tools*
The moose likes Servlets and the fly likes Servlet containers and static resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet containers and static resources " Watch "Servlet containers and static resources " New topic
Author

Servlet containers and static resources

Alexey Gor
Greenhorn

Joined: Jul 13, 2004
Posts: 27
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!
Jon Emerson
Greenhorn

Joined: Feb 19, 2006
Posts: 5
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.


Jon Emerson<br /> <a href="http://www.jonemerson.net" target="_blank" rel="nofollow">http://www.jonemerson.net</A>
Alexey Gor
Greenhorn

Joined: Jul 13, 2004
Posts: 27
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?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet containers and static resources