CURL en jsp

By govani Jan 12, 2011


/*
Hay que descargar el CURL desde la pagina oficial
http://curl.haxx.se/
*/<%@page import="java.io.*" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
"http://www.w3.org/TR/html4/loose.dtd">



<%
try{

Runtime r = Runtime.getRuntime();
String mycurl = "/curl.exe http://172.27.2.38:7001/NECE_SOA-JSONExample-context-root/products/1";
//String mycurl = "dir";

Process p = r.exec(mycurl);

InputStream is = p.getInputStream();
StringBuffer buf=new StringBuffer();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int readByte = -1;
while ((readByte = is.read()) > -1) {
buf.append((char)readByte);
}
// String mybuf = buf.toString();

out.println(buf.toString());

}catch(Exception e){
e.printStackTrace();
out.println(e);
}

%>

By govani

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *