org.weborganic.berlioz.servlet
Class RedirectFilter

java.lang.Object
  extended by org.weborganic.berlioz.servlet.RedirectFilter
All Implemented Interfaces:
Serializable, javax.servlet.Filter

public final class RedirectFilter
extends Object
implements javax.servlet.Filter, Serializable

A basic filter to redirect URI patterns to other URI patterns.

The redirect mapping can be specified as below:

<?xml version="1.0" encoding="utf-8"?>
 <redirect-mapping>
   <redirect from="/"             to="/html/home"/>
   <redirect from="/index.html"   to="/html/home"/>
   <redirect from="/html"         to="/html/home"/>
   <redirect from="/xml"          to="/xml/home"/>
   <redirect from="/{+path}.psml" to="/html/{+path}"/>
 </redirect-mapping>
 

All redirects are currently temporary (302) unless the attribute 'permanent' is set to 'yes' in which case the HTTP code will be 301

See #init(javax.servlet.ServletConfig) for details for configuration options.

Since:
Berlioz 0.7
Version:
Berlioz 0.9.15 - 30 January 2013
Author:
Christophe Lauret
See Also:
HTTP/1.1 - Moved Permanently, HTTP/1.1 - Found, Serialized Form

Constructor Summary
RedirectFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
           
 void doHTTPFilter(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.FilterChain chain)
          Do the filtering for a HTTP request.
 void init(javax.servlet.FilterConfig config)
          Initialises the Redirector Servlet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedirectFilter

public RedirectFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
Initialises the Redirector Servlet.

This servlet accepts the following init parameters:

Specified by:
init in interface javax.servlet.Filter
Parameters:
config - The filter configuration.
See Also:
Servlet.init(javax.servlet.ServletConfig)

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest req,
                     javax.servlet.ServletResponse res,
                     javax.servlet.FilterChain chain)
              throws javax.servlet.ServletException,
                     IOException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException
IOException

doHTTPFilter

public void doHTTPFilter(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res,
                         javax.servlet.FilterChain chain)
                  throws javax.servlet.ServletException,
                         IOException
Do the filtering for a HTTP request.

Parameters:
req - The HTTP servlet request.
res - The HTTP servlet response.
chain - The filter chain.
Throws:
IOException - Should an error occurs while writing the response.
javax.servlet.ServletException - If thrown by the filter chain.