This article explains about determining the type of the browser using Custom Filter class
Create a Custom Filter class which implements Filter Interface, get the "User-Agent" from HttpServletRequest class as shown below.
Create a Custom Filter class which implements Filter Interface, get the "User-Agent" from HttpServletRequest class as shown below.
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain filterChain){
if(servletResponse instanceof HttpServletResponse && servletRequest instanceof HttpServletRequest ){
HttpServletResponse response = (HttpServletResponse)servletResponse;
HttpServletRequest request = (HttpServletRequest)servletRequest;
// This will determine what type of the browser user sends requrest from
String userAgent=request.getHeader("User-Agent");
}
}
No comments:
Post a Comment