• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets, what does this code mean (PrinterWriter Writer = response.getWriter();)  RSS feed

 
Vin Pal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the function of ......PrinterWriter Writer = response.getWriter()...whats does it do. what does it actually mean. I finished learning Java basics, and now learning Servlets and Jsp, Kindly explain in very simple terms.
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that actually "PrintWriter"?

A PrintWriter is a text Writer that understands output in terms of lines. It supports the various "println()" functions.

You need a text Writer to serve as a channel for the Response output text. Using a PrintWriter makes it possible to produce servlet output that's arranged in lines instead of one enormous single line and by using the "println()" methods you don't have to emit brute-force (and OS-dependent) end-of-line characters to do so.

HTML generally doesn't pay much attention to spaces and control characters, but it does help when you want to display source for a web page.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!