dev@jsftemplating.java.net

Serving resource files...

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Mon, 16 Oct 2006 23:14:37 -0700

I added some functionality that provides a convenient way to package and
serve resource files (.js, .css, .jpg, .gif, etc.). To use it, you must
provide a servlet prefix servlet mapping to the FacesServlet:

  <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>/resource/*</url-pattern>
  </servlet-mapping>

Then make requests like:

    http://server:port/context-root/resource/<resource-file-name>

Where <resource-file-name> is relative to the docroot, or stored in the
classpath (i.e. in a .jar file in the WEB-INF/lib directory).

The "/resource/*" pattern is configurable via the context-param
"com.sun.jsftemplating.RESOURCE_PREFIX". You can set this to something
like: "/differentPrefix" -- don't include the trailing "/*". If this
context-param is not set, it will default to: "/resource".

I have not done a lot of testing yet... I have confirmed the basic
functionality works and that the correct "Last-Modified" /
"If-Modified-Since" headers are used.

This functionality is not yet secure, and the semantics may change... so
don't consider this functionality completely stable. I am open to
comments. FYI, I am currently considering either limiting the resources
served to a sub-directory (package), or excluding certain file
extensions -- let me know if you have an opinion on this matter.

Thanks!

Ken