This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

IllegalStateException from jspwriter

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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 pages use a different Streaming mechanism to Servlets.
Choice 3
JSP pages have more security settings than Servlets.
Choice 4
JSP has already opened the stream as a JspWriter.
Choice 5
JSP pages must flush their buffers before changing the stream type; Servlets do not have this limitation.
i think 5 is the answer. Iam not sure . will somebody explain please
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I vote for choice 4. A JSP page is built around the assumption that the output will be HTML and will be written with a Writer.
For binary output, just use a servlet.
Bill
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic