A JSP page is compiled into a Servlet; therefore, it can do everything that a Servlet can do.
However, why is an IllegalStateException thrown when opening a Binary Stream output to the client from a JSP page but NOT to a Servlet?
Select answer from below
JSP pages can write a Binary Stream using its implicit out stream.
JSP pages use a different Streaming mechanism to Servlets.
JSP pages have more security settings than Servlets.
JSP has already opened the stream as a JspWriter.
JSP pages must flush their buffers before changing the stream type; Servlets do not have this limitation.
JSP has already opened the stream as a JspWriter
where as i know, servlet can't give its output simultaneously in the char-bin stream. once you start streaming characters, you can't stream binary data. JSPs are always converted to servlets and then compiled. as soon as you write the <html> tag in your JSP, JspWriter is open, and now you can't sream binary. the best idea is, use dedicated servlets which streams desired binary for you, and call them from withing a JSP whenever the binary data is requiered.
hope this helps you :)