• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP can't send a binary file

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since JSP Engine creates a JSPWriter (out) object from resonse, if we call response.getOutpuStream(), we will always get IllegalStateException @ runtime.

This concludes that we can't send a binary file (data) to client using JSP.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes actually you cannot call response.getOutputStream() after calling response.getWriter() in any servlet.

and jsp translates and compiles down to a servlet, and implicit out object is being got from getWriter() method, so we can not send Binary Stream in JSP page.

Kind Regards
 
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So does it mean we can only send binary data through Servlet?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hendy,
The answer to your question is we can send text as well as binary data using servlet but not both at a time.

My original question was :

Can we send binary data through JSP anyhow ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

We can send text as well as binary data using servlet but not both at a time.


I don't quite like the way this is phrased - text bytes are a subset of all (binary) bytes characters.

Can we send binary data through JSP anyhow ?


Practically, no. Have a look at the Java source code that gets created from a JSP page, and you'll notice the difficulties.
 
reply
    Bookmark Topic Watch Topic
  • New Topic