Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Diff in opening binary stream in JSP & Servlet

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JSP page is compiled into a Servlet; therefore, it can do everything
that a Servlet can do.
If the above statement is TRUE, then why is an IllegalStateException
thrown when opening a Binary Stream output to the client from a JSP page
but NOT to a Servlet?
Choice 1,JSP pages can write a Binary Stream using its implicit out stream.
Choice 2,JSP has already opened the stream as a JspWriter.
Choice 3,JSP pages must flush their buffers before changing the stream type;
Servlets do not have this limitation.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason is choice 2. The signature of JspWriter class is public abstract class JspWriter extends java.io.Writer, and the implicit variable out is an JspWriter. As the translated servlet opens an JspWriter it throws an IllegalStateException.
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic