Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JSPWriter vs. PrintWriter

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Ken
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic