tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Knowles <r...@knowleses.org>
Subject Re: AW: DefaultServlet and getOutputStream() / getWriter()
Date Sat, 09 Oct 2004 09:39:39 GMT
Steffen,

My understanding (and I might be wrong here, so someone please correct 
me if I am) is that once you've called getWriter(), you can't call 
getOutputStream() on the same request. The reason is primarily so that 
you have to use the same char encoding etc on included servlets as in 
the including servlet.

Calling getOutputStream after getWriter results in an exception being 
thrown in Tomcat, hence the try/catch.

Rick Knowles

PS And for the record, I thought Remy's response was pretty harsh too.

Steffen Heil wrote:

>Hi
>
>
>  
>
>>That's definitely why I am not interested by code cleanups done by folks
>>    
>>
>who might not know all the small tricks: the risk of breaking stuff is far
>greater than the gain.
>
>Why are you soo hostile?
>I am just trying to get into the code and if I understand it, I will
>propably start to contribute something. But I need to start somewhere and I
>cannot know "all the small tricks" from beginning. THAT IS WHY I AM ASKING!
>I did not say "remove that shit", nor did I say "this is stupid". I just
>asked why it is done that way.
>
>Additionally, every change I suggested (on tomcat-user) was definitly not
>changing any behaviour, but maybe improving performance.
>
>So I need to give that back to the authors. Things that are not self-evident
>should be documented in code. There is nothing.
>And again, please see, that this is no allegation. But someone will know it
>and it is not in the code, so you should accept questions.
>
>You told me:
>  
>
>>... submit more significant patches ...
>>    
>>
>
>How should I, if I cannot even get information about easy things?
>
>  
>
>>For this particular case, you should look into the API javadocs.
>>    
>>
>
>That's what I have done for some hours.
>
>"Returns a ServletOutputStream suitable for writing binary data in the
>response. The servlet container does not encode the binary data. 
>java.lang.IllegalStateException - if the getWriter method has been called on
>this response 
>java.io.IOException - if an input or output exception occurred"
>
>If I believe that javadocs, THERE IS NO REASON to do what the code does,
>sind getWriter is never called before getOutputStream, so there will never
>be the IllegalStateException and half of the code is obsolete.
>
>That is exactly the reason I am asking.
>
>Regards,
>  Steffen
>  
>

-- 
Servlet v2.4 container in a single 140KB jar file ? Try Winstone (http://winstone.sf.net/)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message