Discussion:
Caching XSLTServlet Filter for XSLTForms.
Stephen Cameron
2014-06-30 14:24:53 UTC
Permalink
I am interested to know if anyone has had a similar idea and successfully
found a way to build this. I have gotten most of the way to what I imagined
but have found a flaw in my plan.

Basically in a HTTP GET, depending on whether the request url ends in .xml
or .html, the filter returns either the raw form or the translated version
after applying xsltforms.xsl to the raw form.

It also caches the translated .html version and returns that for subsequent
requests. If a PUT, POST or DELETE comes through for the raw .xml version
then the cached .html version needs to be expired.

A filter seems to be the best option as the actual source or sink for the
raw form can be any servlet. There are examples of caching filters so it
would seem to be a simple enough thing to build.

However, not so simple, as the filter needs to 'reroute' an URL ending in
.html to one ending .xml before calling doFilter() (so passing the request
up the filter chain) to get hold of an input for the xsltforms.xsl
transform. Sadly it seems this is not actually possible.

Obviously for it to work in a RESTful manner and transparently, both
requests for raw and transformed form versions have to pass through the
same filter.

So, just in the hope that someone might have been here before and knows a
work-around. If not I'll have do it via a servlet as I originally intended.

Thanks
Steve Cameron

Loading...