|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.weborganic.bastille.web.filter.DetectBrowserFilter
public final class DetectBrowserFilter
A Simpler filter class for redirect URL based on User-Agent to different URL.
Sample config in Web Configuration (web.xml)
<filter>
<filter-name>MobileFilter</filter-name>
<filter-class>org.weborganic.bastille.web.filter.DetectBrowserFilter</filter-class>
<init-param>
<param-name>mobile</param-name>
<param-value>http://m.pbs.gov.au</param-value>
</init-param>
<init-param>
<param-name>normal</param-name>
<param-value>http://www.pbs.gov.au</param-value>
</init-param>
</filter>
Constructor Summary | |
---|---|
DetectBrowserFilter()
|
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 filter. |
static boolean |
isMobile(String userAgent)
Indicates whether the specified user agent is a mobile device or not. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DetectBrowserFilter()
Method Detail |
---|
public void init(javax.servlet.FilterConfig config) throws javax.servlet.ServletException
This servlet accepts the following initialisation parameters:
mobile
The mobile site address (eg. 'http://m.acme.gov.au')
normal
The normal site address (eg. 'http://www.acme.gov.au')
Both parameters MUST be valid URLs.
init
in interface javax.servlet.Filter
config
- The filter configuration.
javax.servlet.ServletException
public void destroy()
destroy
in interface javax.servlet.Filter
public void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
IOException
javax.servlet.ServletException
public void doHTTPFilter(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.FilterChain chain) throws javax.servlet.ServletException, IOException
req
- The HTTP servlet request.res
- The HTTP servlet response.chain
- The filter chain.
IOException
- Should an error occurs while writing the response.
javax.servlet.ServletException
- If thrown by the filter chain.public static boolean isMobile(String userAgent)
userAgent
- The User-Agent
HTTP header string.
true
if the user agent string matches that of a mobile device;
false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |