Dmitry Beransky wrote:
>
> I'm implementing a filter that needs to process a request based on the
> returned content type.
>

 There was a long discussion about this on the advanced-servlets
list, thread subject:

  "Why no javax.servlet.ServletResponse.getContentType() method?"

 The "solution" is to have your filter wrap the response, then
manually catch every possible way that the content type can be set,
and use that info to write your own getContentType(). (The Sun
example is just wrong) You'll have to read that thread for a
balanced discussion, because the following explanation is not
exactly even-handed :-)


RANT WARNING

 I put "solution" in quotes because it's plainly not a very
reasonable thing to do. Content-Type in particular is hard,
because setContentType() isn't the only thing that modifies it,
you'd also have to trap setLocale() (and who knows what else?)

 Plus, of course, using this approach means that each Filter is
more or less required to add yet another layer of wrappers to
the request and response. Wrappers hurt performance, bloat the
code, and worst of all, make debugging insanely hard. I mean,
with all those wrappers, who knows what calls are actually
being made? Is it my code, or the 4th Filter from the left
that's causing the problem?

 Filters are a terribly cool concept, but there are some
serious problems with the way they're done in the current
spec.

 Please excuse the rant, I just implemented initial support
for filters in (shameless plug):

 MinTC "The Friendly Embeddable Servlet Container"
 http://www.distributopia.com

and was apalled at the coding style they encourage. I pity
the sucker who has to tune or maintian webapps written using
Filters.


HERE ENDETH THE RANT


I'm sure some Filter advocates will chime in with an
opposing viewpoint :-)


--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to