1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@page contentType="image/png" %>
<%
OutputStream o = response.getOutputStream();
URL image = new URL("url/image.jpg");
URLConnection imageCon = image.openConnection();
InputStream is = imageCon.getInputStream();
byte[] buf = new byte[32 * 1024]; // 32k buffer
int nRead = 0;
while( (nRead=is.read(buf)) != -1 ) {
o.write(buf, 0, nRead);
}
o.flush();
o.close();// *important* to ensure no more jsp output
return;
%> |