• 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

OutputStream instead of out

 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is anything wrong in using getOutputStream rather than using PrintWriter in JSP?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't be, I've used it on occasion. There are a few dangers though. You have to make sure no character data is printed, including white-space. You also lose your error page, since it makes use of 'out' and you can't have both.
With white-space, you have to join your scriptlets and other JSP tags together so there is no data leaking through. You also have to make sure there is no carriage return at the end. To link tags together, you have to do this:

and not this:

I'm not aware of any vendor specific behaviour here.
Dave
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
Thanks.
Can you tell me why I should not have any space between page tag and the scriptlet.
I am doing the following

So, You have changed your signature.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP have the built in assumption that you will be wanting to output a mix of the text that appears between the JSP tags and the output of the Java methods created by the tags. All output is assumed to be characters and will be subject to unicode conversion.
Use a servlet to output binary data such as images, etc.
Bill
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill,
Well I am forced to use a JSP. No choice!


I am outputing HTML code from OutputStream.
reply
    Bookmark Topic Watch Topic
  • New Topic