Helma Logo
main list history

Version 8 by tobi on 02. November 2009, 17:48

1<strong>Due to the recent update to Jetty 6.1 in Helma the options described in this document only apply to Helma versions <=1.6.3.</strong>
2

Version 7 by tobi on 20. October 2008, 16:06

79If someone else is more reluctant successful here please let me know. (However, I guess it's a bug in UrlRewriteFilter we will have to wait for being fixed.

Version 6 by tobi on 20. October 2008, 16:05

15Apply the patch to the Java source of UrlRewriteFilter and compile by invoking <code>ant dist-jar</code>. The resulting JAR file is located in the <code>./dist/urlrewrite-3.1.0/webapp/WEB-INF/lib/</code> directory and needs to be moved to Helma's lib/ext directory.
17(Alternatively to the linked patch above you also can use the one  provided in the attachments or simply copy the attached urlrewrite-3.1.0.jar file in Helma's <code>lib/ext</code> directory.

Version 5 by tobi on 20. October 2008, 15:47

71It's Its main purpose is to rewrite any Antville.org URL by appending the server part (ie. the <em>foo</em> in foo.antville.org) after the basic path <code>/helma/antville/</code>, and thus, enabling host-based weblogs.

Version 4 by tobi on 20. October 2008, 15:47

71It's main purpose is to rewrite any Antville.org URL by appending the server part (ie. the <em>foo</em> in foo.antville.org) after the basic path <code>/helma/antville/</code>, and thus, enabling host-based weblogs.
72

Version 3 by tobi on 20. October 2008, 15:43

25The configuration prompts the web application to reload a file called rewrite.xml (also located in the WEB-INF directory) every 60 seconds. This file contains the rewrite rules (see below).
33Here's the basic setup content of the rewrite.xml file I started with for emulating the current Apache rewrite rules at Antville.org:

Version 2 by tobi on 20. October 2008, 15:33

19<% this.attachments %>
20
37

Version 1 by tobi on 20. October 2008, 15:28

1The only reason why I make such a fuss about how to configure web applications with Jetty and Helma is the option of using servlet filters in web applications.
3Especially the *UrlRewriteFilter|http://urlrewritefilter.googlecode.com* drew my attention because rewriting URLs is currently the only missing feature imagining Antville.org running without the great Apache webserver and with Jetty only...*
4
5Anyway, here's outlined how I made Jetty do the same what Apache 2.0 currently does at Antville.org.
6
7<small>* Why I would imagine such a thing, you ask? I guess it's partly performance tweaking, partly pure curiosity.</small>
8
9=== Prerequisites
10
11* *Helma patched and configured|http://dev.helma.org/wiki/Setting+Up+A+Web+Application+With+Jetty+And+Helma+1.x/* to run web applications
12* *UrlRewriteFilter 3.1.0|http://urlrewritefilter.googlecode.com/files/urlrewritefilter-3.1.0-src.zip* source
13* *Patch|http://code.google.com/p/urlrewritefilter/source/diff?spec=svn166&r=166&format=side&path=/trunk/src/java/org/tuckey/web/filters/urlrewrite/RuleBase.java&old_path=/trunk/src/java/org/tuckey/web/filters/urlrewrite/RuleBase.java&old=146* fixing functions in Url Rewrite Filter
14
15Apply the patch to the Java source of UrlRewriteFilter and compile by invoking <code>ant dist-jar</code>. The resulting JAR file is located in the <code>./dist/urlrewrite-3.1.0/webapp/WEB-INF/lib/</code> directory.
16
17(Alternatively to the patch above you also can use the one provided in the attachments or simply copy the attached urlrewrite-3.1.0.jar file in Helma's <code>lib/ext</code> directory.)
18
19=== Enabling UrlRewriteFilter
20
21Add the contents of the attached file url-rewrite-for-web.xml to the desired web application configuration file web.xml (in some WEB-INF directory).
22
23The configuration prompts the web application to reload a file called rewrite.xml (also located in the WEB-INF directory) every 60 seconds.
24
25Furthermore, it defines the URL path <code>/rewrite-status</code> dumping the current status of the UrlRewriteFilter for debugging.
26
27=== Defining Rewrite Rules
28
29The syntax for the rewrite rules of UrlRewriteFilter are very well documented in the corresponding *manual|http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.1/index.html#configuration*.
30
31Here's the basic setup I started with for emulating the current Apache rewrite rules at Antville.org:
32
33  <?xml version="1.0" encoding="utf-8"?>
34  <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
35    "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
36
37  <urlrewrite>
38      <rule>
39        <from>
40            ^/helma/static/antville(.*)$
41        </from>
42        <to>
43            /helma/static/antville$1
44        </to>
45      </rule>
46      <rule>
47        <condition type="server-name">
48            ^(?:www\.)?antville\.org$
49        </condition>
50        <from>
51            ^/(.*)$
52        </from>
53        <to>
54            /helma/antville/$1
55        </to>
56      </rule>
57      <rule>
58        <condition type="server-name">
59            ^[^.]+\.antville\.org$
60        </condition>
61        <from>
62            ^/(.*)$
63        </from>
64        <to>
65            /helma/antville/${replace:%{server-name}:.antville.org:}/$1
66        </to>
67      </rule>
68  </urlrewrite>
69
70=== Defining Rewrite Rules <code>mod_rewrite</code> Style
71
72Although it says in the manual that UrlRewriteFilter rules can be defined with the *syntax used by Apache and the <code>mod_rewrite</code> module|http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.1/index.html#mod_rewrite_conf* I did not manage to get the filter working like this.
73
74Instead, I always get the same output of rewrite-status as described in this *posting|http://groups.google.com/group/urlrewrite/browse_thread/thread/49d7da989c6fbc80/b78aaae8c8d23411?hl=en&lnk=gst&q=mod_rewrite#b78aaae8c8d23411* to the UrlRewriteFilter discussion group.
75
76If someone else is more reluctant here please let me know. (However, I guess it's a bug in UrlRewriteFilter we will have to wait for being fixed.)