This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletOutputStream  RSS feed

 
Sunder Ganapathy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!