• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

doubt in explanation

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all....i am new to javaranch...i found this on javabeat.com

what does this mean?

It is possible to produce only one type of output (either character-based or binary-based)

...but when i run a similar example on netebans i dont get any error
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've not provided enough information to help you. The statement says so because you can only call either response.getOutputStream (binary output stream) or response.getWriter (text output stream) on a response object. So you can say that we can write either binary or text (character) based response. If you show us the example which you say is working, we'll be able to help you further...
 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but i want to know the reason for this...i have closed the stream of printwriter before opening for the output stream...

i only get mosby as the output and an error....why?
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Garg wrote:you can only call either response.getOutputStream (binary output stream) or response.getWriter (text output stream) on a response object.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Coincidentally I just came from another topic that contained a similar ambiguity about the word "only":

A JAR file can contain classes from only a single package


(From the SCJP 6 prep book. The book claimed this was a wrong statement. But of course a JAR file can contain classes from only a single package.)

In this case:

you can only call either response.getOutputStream (binary output stream) or response.getWriter (text output stream) on a response object.


Example of the ambiguity:
You can only get into the house either through the back door, or through the basement window.

My two burgler friends are happy to discover that entry by the back door does not preclude entry also through the basement window.

Unambiguous to say, perhaps, that you can only call one of either .getOutputStream or .getWriter.

 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but what if i enter the house from the front door to find demons and then come outside only to enter from the backdoor to save my love...means what if i oen outputstream...then close it and then open the writer?
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ted mosby wrote:but what if i enter the house from the front door to find demons and then come outside only to enter from the backdoor to save my love...means what if i oen outputstream...then close it and then open the writer?


What happened when you tried it?? When you close the OutputStream or Writer, the connection with the client is lost, so you cannot call the other one after closing the first one...
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Ted.

but what if i enter the house from the front door to find demons and then come outside only to enter from the backdoor to save my love...means what if i oen outputstream...then close it and then open the writer?



As 'Ankit' said, if we close OutputStream or Writer, connection between client and server is lost. If you find demons when you enter through front door, clear the demons first and forward the resource(using RequestDispatcher's forward() method) to save your love.

 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic