Web Server: Custom URL Rewrite Rule Tutorial
From Resin 4.0 Wiki
<web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:org.example.mypkg"> <mypkg:MyDebugRewrite regexp="^/test/" target="/new/"/> </web-app>
MyDebugFilterChain.java
package qa; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class TestFilterChain implements FilterChain { private String _target; public TestFilterChain(String target) { _target = target; } public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) request; PrintWriter out = response.getWriter(); out.println("URI: " + req.getRequestURI()); out.println("target: " + _target); } }
MyDebugRewrite.java
package qa;
import javax.servlet.*; import javax.servlet.http.*; import com.caucho.rewrite.*; public class Test extends AbstractTargetDispatchRule { @Override public FilterChain createDispatch(DispatcherType type, String uri, String queryString, String target, FilterChain next) { return new TestFilterChain(target); } }