This is a Java servlet filter (as per Servlet API 2.3). This filter lets you redirect incoming requests according to some mapping table. So, you may use it for example as an access restriction tool, for load balancing etc.
How to use it:
a) download redirectflt.jar and save it in WEB-INF/lib
b) create a data file with you mapping info. It is a text file, each line describes an
action for one source URI. Empty lines and any line starts with // or #
are ignored. Path to this file should be provided as a parameter for RedirectFilter.
Parameter name is config. Each action looks like:
here the request to /a/test.jsp will be redirected to http://www.acme.com and request to /a/test1.jsp will be forwarded to /mypage.jsp.
c) describe this filter in web.xml.
d) describe a mapping for this filter in web.xml. E.g.:
in this example filter will be on for the each .jsp file in /a subdirectory
And now when some .jsp page (covered by RedirectFilter mapping) is requested RedirectFilter may redirect (or forward) request to the specified URL. If target URL starts with http than request will be redirected. Otherwise filter assumes a local resource and forwards request. The query string (if any) will be passed to the new site as is.
Note: your data file could be updated in the dynamic, you do not heed to restart this filter.
Also, you can update your redirection info right from the server side application (e.g. Struts action). You may use two methods:
public void com.cj.redirect.addRedirection(String from, String to)
public String com.cj.redirect.getRedirection(String from)
public void com.cj.redirect.removeRedirection(String from)
For dealing with your redirection data right from JSP pages you can use Redirection taglib.
Redirect package: redirectflt.jar
See also JSOS - the largest collection of servlets and filters.
Also in JSOS: