Hi,
can't we do this in JSP,
i am getting the error The method getOutPutStream() is undefined for the type HttpServletResponse
<%
response.getOutPutStream();
%>
I agree with wisw owen
response.getOutPutStream();
response.getOutputStream();
[ June 05, 2006: Message edited by: wise owen ]
because the error is"method is undefined"
In fact, even if you do use the correct method name, you'll find you get an IllegalStateException. The reason is that JSPs use a JspWriter behind the scenes, so in fact the getWriter method was already invoked. By the contract of ServletResponse, it is illegal to invoke both getOutputStream() and getWriter().
Why would you want to invoke both anyway; the mere fact you're using a JSP implies that you are writing a textual (e.g. HTML, XML) response. The output stream should be used for binary responses.
in case that we need to render image for jsp just need to set
<%response.setContentType="image/jpeg";%>
and assign your getOutputStream to a variable, all is work and no illegal
the snippet is
byte[] b = null;
b = (byte[])o;
if(b != null)
{
response.setContentType("image/jpeg");
OutputStream ox = response.getOutputStream();
ox.write(b);
ox.close();
}