au.com.lastweekend.pathinfo
Class PathInfoFilter

java.lang.Object
  extended by au.com.lastweekend.pathinfo.PathInfoFilter
All Implemented Interfaces:
javax.servlet.Filter

public class PathInfoFilter
extends java.lang.Object
implements javax.servlet.Filter

Allow URLS of the form context/*.ext/pathInfo

There is no way to directly map a servlet so that context/anyscript.cgi/somePathInfo ends up with a
request with servletPath = context/anyscript.cgi, pathInfo = somePathInfo

Either map *.cgi which won't match or map context/specificscript.cgi/somePathInfo which can only match those scripts that are specifically mapped.

Example for PHP

Map this filter to match the root context InitParam pathSpec = "*.php"

Map a PHP servlet to "*.php"

TODO: Allow multiple pathSpecs to be matched.

Version:
$Id$
Author:
Grant Gardner grant@lastweekend.com.au

Constructor Summary
PathInfoFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
          The filter operation.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
 void init(javax.servlet.FilterConfig config)
           
 void setPathSpec(java.lang.String pathSpec)
          Init-param "pathSpec" of the form "context*extension" but typically "context/*.ext"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathInfoFilter

public PathInfoFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

destroy

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

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     javax.servlet.FilterChain chain)
              throws javax.servlet.ServletException,
                     java.io.IOException
The filter operation.

If request.servletPath() matches the pathSpec
ie begins with context and has a path component ending in extension.

wrap providing new implementations of getServletPath() and getServletPathInfo() and forward otherwise pass through to the chain.

TODO: Find out what should happen when extension appears more than once. eg (phpinfo.php/phpinfo.php/pathInfo).

Parameters:
request -
response -
chain -
Throws:
javax.servlet.ServletException
java.io.IOException

setPathSpec

public void setPathSpec(java.lang.String pathSpec)
Init-param "pathSpec" of the form "context*extension" but typically "context/*.ext"

Parameters:
pathSpec -


Copyright © 2008. All Rights Reserved.