The example below shows how to open a binary output stream from a JSP.

Java Code:
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@page contentType="image/gif" %><%
    OutputStream o = response.getOutputStream();
    InputStream is = 
      new URL("http://myserver/myimage.gif").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; 
%>