views:

215

answers:

1

So after installing UrlRewriteFilter, I set up a rule and a corresponding velocity template. And when I go to the test page, the velocity script is shown as raw code instead of being compiled.

example of the code for the rule:

<rule>
   <from>/test/([0-9]+)</from>
   <to>/downloads/test.vm?Id=$1</to>
</rule>

example of the urlrewritefilter

<filter>
   <filter-name>UrlRewriteFilter</filter-name>
   <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    <init-param>
        <param-name>logLevel</param-name>
        <param-value>DEBUG</param-value>
    </init-param>
</filter>

any ideas why the velocity template wouldn't render even though the rule executed correctly? All other vm pages render correctly (when accessed directly) and the rewrite works perfectly with jsp.

+1  A: 

This happens when the test.vm is served by the default servlet for static content.

I suspect you changed the mapping for velocity somehow. If you are using Velocity Tools, you should have a mapping like this,

<servlet>
  <servlet-name>velocity</servlet-name>
  <servlet-class>
    org.apache.velocity.tools.view.VelocityViewServlet
  </servlet-class>
</servlet>

<!-- Map all *.vm files to Velocity -->
<servlet-mapping>
  <servlet-name>velocity</servlet-name>
  <url-pattern>*.vm</url-pattern>
</servlet-mapping>

Another possibility is that other filter might interfere with UrlRewrite filter. It would be helpful if you can post your web.xml.

ZZ Coder
thanks very much for the tip, i don't want to display the contents of my web.xml but im looking through now to see if that servlet mapping is handled elsewhere
Benjamin Neil
looked it over again and it was a mapping issue in the web.xml, thanks again for the help
Benjamin Neil