This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Why no HttpServletReq on doFilter? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why no HttpServletReq on doFilter?" Watch "Why no HttpServletReq on doFilter?" New topic
Author

Why no HttpServletReq on doFilter?

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
Seems odd (to me anyway) that doFilter would not take HttpServletRequest as input...aren't most filters going to apply to Http?
--->public void doFilter(
ServletRequest req,
ServletResponse resp,
FilterChain chain)
throws ServletException, IOException {

So if, for example, to get pathInfo, I have test for instanceof HttpServletRequest, then cast to it, just to get some basic info.
Or am I missing something?
thanks,
max
Steve Leach
Ranch Hand

Joined: Sep 24, 2003
Posts: 46
Filters aren't Http specific. If you *know* that you are only going to get HttpServletRequests (which is reasonable) then you are safe to cast without checking.
Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
OK, thanks.
Where would I want to use a non-http filter?
Max
 
 
subject: Why no HttpServletReq on doFilter?
 
Similar Threads
accessing a session attribute from a class that implements Filter
LoginFilter & j_security_check
Filter Issue
setting an object in session using Filter
If anybody can answer these two questions?