This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletOutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletOutputStream" Watch "ServletOutputStream" New topic
Author

ServletOutputStream

Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
In page 205 of HFSJ, it mentioned as follows.
OutputStream os = response.getOutputStream();
As per specs, getOutputStream() returns ServletOutputStream object.
Then how come it is mentioned only as OutputStream?
Gab Buda
Greenhorn

Joined: Mar 25, 2006
Posts: 24
Hi Sunder,

OutputStream os = response.getOutputStream(); is a legal statement since javax.servlet.ServletOutputStream extends java.io.OutputStream.
In the example they use the method os.write() (which comes from OutputStream), so there is no need to use ServletOutputStream. Both are legal, this is just an arbitrary choice I think.


Gabb


SCJP 1.4 (85%)<br />SCWCD 1.4 (94%)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ServletOutputStream