A mini-pipeline -- this Components functions as a complete self-contained pipeline.

The simplest implementation is the Resource Reader, which simply reads a file from disk and streams it back to the user#1.


<map:readers default="resource">
  <map:reader name="resource" src="org.apache.cocoon.reading.ResourceReader"/>


<map:match pattern="sites/images/*.gif">
  <map:read src="resources/images/{1}.gif" mime-type="image/gif"/>

Note that the map:read element requires a mime-type attribute that indicates the mime-type of the file being served#2.

See also ServingStaticFiles

Available Implementations

Readers Comments

Note that ResourceReader actually uses Sources. So it's by far not restricted to files. The SourceResolver will automatically choose which Source to use in order to aquire the data by looking at the contents of the src attribute. AFAIK there are Sources for reading from the file system, from the CLASSPATH, from ftp and from http plus it's easy to add your own.

Note that at least for Cocoon 2.1 the mime-type can also be determined by the Source, if it is able to provide it. The mime-type attribute can be used to override this. Otherwise the mapping from extensions to mime-types of your servlet container (Tomcat: web.xml) will be used.

Reader (last edited 2009-09-20 23:41:29 by localhost)