Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OutputStream instead of out  RSS feed

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is anything wrong in using getOutputStream rather than using PrintWriter in JSP?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,
Well I am forced to use a JSP. No choice!


I am outputing HTML code from OutputStream.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!