Saturday, November 7, 2009

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: