May 24, 2009

UrlRewriteFilter - URL Rewriting Example with Java

« JUNG - Graphen modellieren mit Java | Main | SSH Server sicher machen »

The UrlRewriteFilter-Engine represents the J2EE counterpart of the Apache mod_rewrite module. It supports all base functions of a standard url rewrite engine and more.

  • URL Abstraction - e.g. mapping from /Login.html -> /jsp/login.jsp
  • Evaluation of several HTTP/Browser Parameters - e.g. url rewriting based on session ids, cookie values, header values et cetera
  • Method Invocation - e.g. url rewrite rule invokes a Java class method
  • Several URL rewrite methods - redirect, forward, proxy and so on
  • Inbound and Outbound Rewriting - rewriting of urls and hyperlink urls of the web applications behind

A small example:
pom.xml

<dependency>
  <groupId>org.tuckey</groupId>
  <artifactId>urlrewritefilter</artifactId>
  <version>3.1.0</version>
</dependency>
web.xml filter configuration
<filter>
  <filter-name>UrlRewriteFilter</filter-name>
  <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  <init-param>
    <param-name>confReloadCheckInterval</param-name>
    <param-value>1</param-value>
  </init-param>
  <init-param>
    <param-name>logLevel</param-name>
    <param-value>INFO</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>UrlRewriteFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
urlrewrite.xml (WEB-INF directory):
<rule>
  <from>^/tidy/page$</from>
  <to>/old/url/scheme/page.jsp</to>
</rule>

Regards
Rafael

Technorati Tags:

Posted by rafael.sobek at 9:55 PM in Uncategorized

 

« May »
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
31