File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion 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: 63873

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: 13037
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.
It is sorta covered in the JavaRanch Style Guide.
subject: Binary Data and JSP
It's not a secret anymore!