File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why no HttpServletReq on doFilter?

 
Max Tomlinson
Ranch Hand
Posts: 365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thanks.
Where would I want to use a non-http filter?
Max
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic