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.
Most Recent jsp Faqs
- How to get the real requested URI from inside the error page?
- Can I define a method in a JSP page?
- What is the difference between request.getParameter() and request.getAttribute()?
- What is difference between page and pageContext in JSP pages?
- How to config a JSP file in web.xml?
- What is the difference between jsp:forward and response.sendRedirect?
- How to retrieve values from HTML form input elements in JSP?
Most Viewed jsp Faqs
- How to config a JSP file in web.xml?
- What is difference between page and pageContext in JSP pages?
- How to disable browser caching for a specific JSP?
- How to retrieve values from HTML form input elements in JSP?
- What is the difference between jsp:forward and response.sendRedirect?
- What is the difference between request.getParameter() and request.getAttribute()?
- How to get the current JSP page name?