wood burning stoves
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSPWriter vs. PrintWriter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSPWriter vs. PrintWriter" Watch "JSPWriter vs. PrintWriter" New topic

JSPWriter vs. PrintWriter

Ken Duncan
Ranch Hand

Joined: Apr 30, 2007
Posts: 51
JSPs get translated to servlets. According to the Heads First book, on p.age 338, "out" is a javax.servlet.jsp.JspWriter. So I have two questions. First, is there a way to know, besides memorizing details in the spec, to know when something is a "servlet" class and when something is a "JSP" class? In the preceding pages, the book emphasizes that application, request, etc., are servlet-related classes because every JSP is turned into a servlet. Having out be a JSPWriter and not a PrintWriter seems to be an exception to this "rule," so I'm concerned to be able to tell the difference. Second, what does a JSPWrtier get translated into in the generated servelet class? Thanks.

amer abushamma

Joined: Jul 12, 2010
Posts: 10
JSPs should use the JspWriter denoted by the “out” implicit object for sending output back to the client. A
JspWriter is a buffered version of the PrintWriter. Refer JspWriter API for details. JspWriter also differs from a PrintWriter by throwing java.io.IOException, which a PrintWriter does not. The advantage of throwing an exception is that if your HTTP connection is broken for some reason, your JSP won’t sit there trying to send characters to a broken connection.
I agree. Here's the link: http://aspose.com/file-tools
subject: JSPWriter vs. PrintWriter
It's not a secret anymore!