• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we set Servlet output stream manually?

 
indu pai
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a servlet which takes in the request and sends a html page with some message. for displaying this html page the following code is used.

output = response.getOutputStream();
output.print("this is file");
output.flush();

How will i know what is the Servlet output stream returned? is it a URL, on which the html file has to be displayed?Can i set it manually?

Indu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An output stream is for returning binary data to the client.

If you want to write text, call response.getWriter.

Example:
 
amarnath nalumachu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can wrap to any output stream that you wish to deal with. Assume if you want your servlet to return html page then response.getWriter()/response.getOutputStream() is sufficient. But if you want your servlet to stream a zip a file, then you need to wrap the response.getOutputStream() to appropriate output stream.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"amarnath n",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
amarnath nalumachu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi "Bear Bibeault", My first name is "amarnath" and last name is "nalumachu". I thought it is ok to use my lastname initial "n". But anyhow, I have updated my profile.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amarnath nalumachu:
I thought it is ok to use my lastname initial "n".


It is not. Thank you for complying quickly with my request.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic