public
Created

Stream node.js to struts

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
URL url = new URL("http://192.168.128.160:8001/grepper.htm");
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
BufferedInputStream bis = new BufferedInputStream(httpcon.getInputStream());
ServletOutputStream out = response.getOutputStream();
log.debug("streamopen");
byte[] outputByte = new byte[4096];
int i=0;
//copy binary content to output stream
while ((i = bis.read(outputByte, 0, 4096)) != -1) {
log.debug("stream "+i+" bytes");
out.write(outputByte, 0, i);
}
 
httpcon.disconnect();
bis.close();
out.flush();
out.close();
return null;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.