tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Pardon <l...@skopos.be>
Subject Re: OutputStream cleanup
Date Sat, 15 Apr 2000 06:19:12 GMT
Costin,

  While you're tinkering in this area, please have a look at Tomcat bug
037. A jsp:included servlet can't use an output stream, because it
conflicts with the writer from the calling servlet.

  Craig thinks this is correct, but I think it's not. I'm still  working
my way through the specs to see if Tomcat (3.1 beta) conforms or not.
Either way, I don't think I should have to care about the particular
implementation of the URI that I'm including. In fact, section B.4 in
JSP 1.1 sayu that "the goal is for jsp:include to be totally transparant
to how the data is computed".

  Indeed, the idea of including - in my view - is to insert (merge) the
byte stream from the included URI into the byte stream that you're
sending to your requester. The way it is now, the incoming bytes are
converted into chars and then converted back again on their way out -
which of course screws up the bytes big time if the encoding isn't
exactly the same in every link of the chain.

  I ran into this because my included servlet was a wrapper for a CGI
script (IBM's Net.Data to be precise) that retrieves data in several
languages and various encodings from a database. My calling servlet
knows which encoding is required by its client, and passes this
information on to the CGI script as a parameter that the script
understands. The wrapper servlet uses byte streams so it shouldn't have
to worry about encoding (I first used a writer and got garbage output
with the deafult encoding). If I can't use a stream (as it is right now)
the wrapper servlet must adjust its encoding to the type of request it
is passing on, instead of being just the go-between. I don't think this
is right.

  It is trivial to fix this, by testing if the servlet isIncluded before
throwing an IllegalStateException. This is especially true if the
buffering cleanup that you are proposing ensures you can cleanly mix
stream and writer within the same request.

  If the current behaviour is correct, the JSP spec should be amended to
say that an URI can be anything, EXCEPT a servlet that calls
getOutputStream() on the request. That seems a Bad Thing (n-tm) to me.

 Luc Pardon
 Skopos Consulting
 Belgium
 http://www.skopos.be

Mime
View raw message