*
The moose likes Servlets and the fly likes Filter doubt 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 "Filter doubt" Watch "Filter doubt" New topic
Author

Filter doubt

philip johnson
Ranch Hand

Joined: Dec 25, 2007
Posts: 40
Hi
In my filter if I get res.getOutputStream(); and I modify it and then flush it, what will happen to the next filter part of same app accessing the same outputstream and trying to modify , since it closed , will it throw illegalStateException, or the webcontainer keep the stream open till all the filters finished.


Philip
SCJP2, SCBCD1.3
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

What happened when you tried it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Angel J Gama
Ranch Hand

Joined: Jun 28, 2007
Posts: 36
Once you commit the response, there is no other thing to commit later.
And when you've commited the response, it'll be sent back to the client. But if you commit the response and then you try to do something with it, then you'll get the IlegalStateException.
If you stop the chain -no call to chain.doFilter()- no other filters are executed, and that makes sense because the chain object knows what resource is in stack (filter, servlet, ...)
[ August 31, 2008: Message edited by: Angel J Gama ]
philip johnson
Ranch Hand

Joined: Dec 25, 2007
Posts: 40
HI
Why I asked I am using third party jars for couple of filters, they are writing to the ServletOutputStream and flushinh it, in two filters it is happening, when you chain it I could not predict the behaviour, sometime it work, sometime it crashed with the outputsteram is already obtained exception. SO my questionis what is the standard way to chain filters, how you change the source if you want to modify the jars.I think the filter provider think you are usingonly this filter.
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Filter doubt
 
Similar Threads
404 Error when trying to use a filter for a servlet
How to filter member listing by group?
Filters chaining order
[Solved][HFSJ] Filter Preferences
Pno-:695 HFS&JSP Filter Sequence