aspose file tools*
The moose likes Servlets and the fly likes java.lang.IllegalStateException: getWriter() has already been called for this response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.lang.IllegalStateException: getWriter() has already been called for this response" Watch "java.lang.IllegalStateException: getWriter() has already been called for this response" New topic
Author

java.lang.IllegalStateException: getWriter() has already been called for this response

Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

I'm trying to access both response.getWriter() and response.outputStream() method
My code


Exeption i'm getting

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.IllegalStateException: getWriter() has already been called for this response
org.apache.catalina.connector.Response.getOutputStream(Response.java:580)
org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:183)
com.example.web.CodeReturn.doGet(CodeReturn.java:21)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.28 logs.

It says i can't access both ,but what if i want to access both ?!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Arun Giridharan wrote:but what if i want to access both ?

You will be disappointed.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Arun Giridharan wrote:It says i can't access both ,but what if i want to access both ?!


Then stop wanting to do that. Why would you want to, anyway? Either you're writing some data which isn't text (like your application which is apparently sending a jar file as the response) in which case you shouldn't be writing text. Or you're writing some data which is text, in which case you should only be writing text.
Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

Paul Clapham wrote:
Arun Giridharan wrote:It says i can't access both ,but what if i want to access both ?!


Then stop wanting to do that. Why would you want to, anyway? Either you're writing some data which isn't text (like your application which is apparently sending a jar file as the response) in which case you shouldn't be writing text. Or you're writing some data which is text, in which case you should only be writing text.


What if my stupid Team-Lead want me to do it !! (i mean how can i do it rather than disappointment!?)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

You can't. So your stupid team leader will be disappointed.

Has he explained why he wants this?
Arun Giridharan
Ranch Hand

Joined: Sep 30, 2010
Posts: 290

Thank You

Paul Clapham and Bear Bibeault
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.IllegalStateException: getWriter() has already been called for this response