Home  |   STIU  |   WOW  |   SCJP  |   SCDJWS   |   JEE FAQ  |   About US  |  
FAQ
  Java FAQ
  JSP FAQ
  Servlet FAQ
 

Advertisement



XyzWs JSP FAQ: Is JSP good for generating binary data?

Is JSP good for generating binary data?


JSP is intended to simplify the programming of dynamic textual content. JSP pages are a presentation-centric, declarative means of binding dynamic content and logic. JSP pages should be used to handle the HTML representation that is generated by a page.

For the following reasons, JSP pages are a poor choice for generating binary data. Generally you should use servlets instead.

  • JSP implementations are not designed to handle binary data--there are no methods for writing raw bytes in the JspWriter object.
  • The JSP engine expects to be generating text data (the underlying input/output mechanisms are text-oriented) and that all template text in a JSP including white-space is emitted as part of the document. During execution. The JSP container preserves whitespace. Whitespace is sometimes unwanted, we can see that using a JSP is a poor choice for generating binary output (a .gif file, for example) to the browser, or for other uses where whitespace is significant.

Servlets are well suited for dynamically generating binary data such as images or a new content type.


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

Support  | Feedback  | Help