File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet containers and static resources

 
Alexey Gor
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Jon Emerson
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic