public class UserAgentFilter extends Object implements Filter
This filter allows efficient matching of user agent strings for downstream or extended filters to use for browser specific logic.
The filter is configured with the following init parameters:
Pattern
to extract the essential elements of the user agent.
The concatenation of matched pattern groups is used as the user agent name(?:Mozilla[^\(]*\(compatible;\s*+([^;]*);.*)|(?:.*?([^\s]+/[^\s]+).*)
. These two
pattern match the common compatibility user-agent strings and extract the real user agent, failing that, the first
element of the agent string is returned.Constructor and Description |
---|
UserAgentFilter() |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain) |
String |
getUserAgent(ServletRequest request) |
String |
getUserAgent(String ua)
Get UserAgent.
|
void |
init(FilterConfig filterConfig) |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doFilter
in interface Filter
IOException
ServletException
public void init(FilterConfig filterConfig) throws ServletException
init
in interface Filter
ServletException
public String getUserAgent(ServletRequest request)
public String getUserAgent(String ua)
ua
- A user agent stringCopyright © 1995-2015 Webtide. All Rights Reserved.