Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

write()??? print()???

 
Wai Yip Lau
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What really is the difference between these two methods in PrintWriter and JspWriter?

I didn't see PrintWriter using write(). But in HFSJ P.295 it seems usual HTML code will go to write() and expression will go to print(). Why is it and what's the difference?? thank you.
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wai,

I don't know that I have an answer that is going to satisfy you fully.
However the API for the JspWriter makes this statement


This abstract class emulates some of the functionality found in the java.io.BufferedWriter and java.io.PrintWriter classes, however it differs in that it throws java.io.IOException from the print methods while PrintWriter does not.


Secondly as a general rule (I think (not 100% sure) the box HFSJ P.294 states that) the servlet code generated by the container for a jsp is vendor dependant and can be very difficult to understand. I am not one for putting much weight in the way that jsp's are truned into servlets. It is interesting code to look at, an on occasions you can learn from it, but it can be very cryptic. I also think, if you are just studying for the exam that it is not required for the exam, maybe someone else can comment on this, although having said that I would encourage you to delve into it and pull things apart to try and work things out at a deeper level if you have the time.

Hope this gives you a few pointers.

Matt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic