getOutputStream and getWriter in servlet

Discussion in 'Java' started by John Smith, Jun 16, 2006.

  1. John Smith

    John Smith Guest

    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
     
    John Smith, Jun 16, 2006
    #1
    1. Advertising

  2. John Smith

    hiwa Guest

    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.
     
    hiwa, Jun 16, 2006
    #2
    1. Advertising

  3. 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.
     
    Andrea Desole, Jun 16, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. b83503104
    Replies:
    1
    Views:
    28,396
    John C. Bollinger
    Dec 1, 2003
  2. circuit_breaker
    Replies:
    2
    Views:
    2,081
    Jack Jia
    Apr 4, 2004
  3. DiscoStu
    Replies:
    6
    Views:
    798
    DiscoStu
    Jul 9, 2004
  4. javadev
    Replies:
    5
    Views:
    13,087
    javadev
    Nov 16, 2006
  5. Hrvoje Niksic
    Replies:
    0
    Views:
    261
    Hrvoje Niksic
    Dec 20, 2010
Loading...

Share This Page