This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

There is a problem while calling the method  RSS feed

 
gurusamy sengodan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to use the following method at the same time.
is it possible?
1)response.getWriter();
2)response.getOutputStream();

I have written two method.
In first method, i am using response.getWriter();
In the second method, i am using response.getOutputStream();
Why because, in one place i have to handle bytes
in another place i have to handle characters.
But while calling the method. i got the exception.
How to handle these things.
 
kishore kovil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i think we cannot use both printwriter and stream objects both at the same time
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kishore is correct.

You can only send back one response per request and that response can not be a mixture of binary and textual data.

Maybe if you describe what you're tryning to do, someone can suggest an alternative.
 
Alex Sotin
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know exactly why do you need 2 responses for 1 request, but I think you can put one of your responses in the http header (if you use it). Please tell us more detailed what are you doing
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!