Tuesday, May 17, 2011

How to write image into jsp?


WriteIamge.jsp
<%
byte[] imagedata=(byte[])request.getAttribute("imageData");
OutputStream output = null;
if(imagedata!=null){ response.setContentType("image/gif"); try{
output = response.getOutputStream();
output.write(imagedata);
out.clear ();
out = pageContext.pushBody ();
}
catch(Exception e)
{
System.out.println("ERROR OCCURED IN Image jsp");
e.printStackTrace();
}
finally
{
output.flush();
output.close();
}
}else{
out.println("

Image not available

");
}
%>

No comments: