tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
Subject Re: Filter to detect a user not logged in
Date Tue, 27 Jan 2004 07:24:22 GMT

"Merrill Cornish" <> wrote in message
> I'm trying to learn filters by writing one to detect when someone who
> has not logged in tries to access a JSP page that requires login.  From
> what I've read, this seems to be one common use of filters.
> I think I understand how to write the filter, but to determine whether
> the session had been logged in, I need to HttpSession object.
> The doFilter() method receives ServletRequest rather than
> HttpServletRequest, so there is no getSession() method.  At the same
> time, since the filter is tied to ServletRequest and ServletResponse, it
> appears that the filter runs at a level "above" individual sessions,
> implying that a filter could never check whether a specific session was
> logged in.

Well, something like:
  HttpServletRequest hreq;
  if(request instanceof HttpServletRequest) { // always true for Tomcat
       hreq = (HttpServletRequest)request;

> Can filters be used to check whether a user is logged in?
> Merrill

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message