Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > getOutputStream and getWriter in servlet

Reply
Thread Tools

getOutputStream and getWriter in servlet

 
 
John Smith
Guest
Posts: n/a
 
      06-16-2006
In a servlet you can call either getOutputStream or getWriter but only one,
calling the other later gets an IllegalStateException. Is there a way of
finding out what has already been called?

Thanks

Jon


 
Reply With Quote
 
 
 
 
hiwa
Guest
Posts: n/a
 
      06-16-2006

John Smith のメッセージ:

> In a servlet you can call either getOutputStream or getWriter but only one,
> calling the other later gets an IllegalStateException. Is there a way of
> finding out what has already been called?
>
> Thanks
>
> Jon


> calling the other later

Just don't do it.

 
Reply With Quote
 
 
 
 
Andrea Desole
Guest
Posts: n/a
 
      06-16-2006
John Smith wrote:
> In a servlet you can call either getOutputStream or getWriter but only one,
> calling the other later gets an IllegalStateException. Is there a way of
> finding out what has already been called?


the best solution is to know what you call. There is no point in writing
binary data to a writer. I would say this is also the meaning of the
exception.

Besides that, I'm afraid the only possibility to know that a method has
been called is to catch the exception when you try to call the other one.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"encoding" attribute codecs.getwriter-produced streams Hrvoje Niksic Python 0 12-20-2010 10:57 AM
Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response javadev Java 5 11-16-2006 11:22 AM
Using getOutputStream with a servlet redirect? DiscoStu Java 6 07-09-2004 06:16 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
getOutputStream() and getInputStream() b83503104 Java 1 12-01-2003 05:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57