This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSP and the fly likes Binary Data and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Binary Data and JSP" Watch "Binary Data and JSP" New topic

Binary Data and JSP

Murali Mohan
Ranch Hand

Joined: Jun 14, 2001
Posts: 47
Hi all I have a basic doubt. How does Servlets is preferred technology to generate binary data than JSP? Any limitation in JSP?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63534

JSP technology was designed from the get-go to process text data. Trying to get it to serve binary data is fraught with gotchas and problems that need to be worked around. Why bother when servlets are so easy to code?
You can use a hammer to divide a board in two. But a saw does a much better job.

[Asking smart questions] [About Bear] [Books by Bear]
Murali Mohan
Ranch Hand

Joined: Jun 14, 2001
Posts: 47
Can u pls elaborate ?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13024
JSP automatically assume you will be sending a character stream. Your JSP page gets a automatic variable "out" that assumes it will be sending characters in some encoding. Sending binary data in a character stream results in garbage. Use a servlet to send binary data, it really is not that hard, I don't know why some people are afraid of servlets.
I agree. Here's the link:
subject: Binary Data and JSP
It's not a secret anymore!