How to set a session in Java Filter?
I make a filter,in this filter,I check a request parameter,if this parameter equals a assigned name,I put a flag into a session,like follows:
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException,ServletException
String name=request.getParameter("name");
.....
if(name.compareTo("John")==0){
session.setAttribute("isLogin","true");
}
...
}
But when I run above program,I will get a error,because session is not defined. I know HttpSession is get by HttpServletRequest.getSession(),
but public void doFilter is only provide ServletRequest,not HttpServletRequest! I want to know whether there is a method which I can get HttpSession in Filter?
Any idea will be appreciated!

