IllegalStateException in getOutputStream method of ServletResponse object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghd
    New Member
    • Sep 2007
    • 22

    IllegalStateException in getOutputStream method of ServletResponse object

    Take a look at the official documentation on the getOutputStream method:

    public ServletOutputSt ream getOutputStream () throws IOException
    Returns a ServletOutputSt ream suitable for writing binary data in the
    response. The servlet container does not encode the binary data.
    Calling flush() on the ServletOutputSt ream commits the response. Either this
    method or getWriter() may be called to write the body, not both.
    Returns: a ServletOutputSt ream for writing binary data
    Throws:
    IllegalStateExc eption - if the getWriter method has been called on this
    response
    IOException - if an input or output exception occurred


    If the getOutputStream can throw the 'IllegalStateEx ception', shouidn't the method be defined as: public ServletOutputSt ream getOuputStream( ) throws IllegalStateExc eption, IOException ?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by ghd
    Take a look at the official documentation on the getOutputStream method:

    public ServletOutputSt ream getOutputStream () throws IOException
    Returns a ServletOutputSt ream suitable for writing binary data in the
    response. The servlet container does not encode the binary data.
    Calling flush() on the ServletOutputSt ream commits the response. Either this
    method or getWriter() may be called to write the body, not both.
    Returns: a ServletOutputSt ream for writing binary data
    Throws:
    IllegalStateExc eption - if the getWriter method has been called on this
    response
    IOException - if an input or output exception occurred


    If the getOutputStream can throw the 'IllegalStateEx ception', shouidn't the method be defined as: public ServletOutputSt ream getOuputStream( ) throws IllegalStateExc eption, IOException ?
    Read all about it here.

    Comment

    Working...