System.out.println("Setting up URLConnection");
URL u = new URL(SERVER);
URLConnection cx = u.openConnection();
cx.setContentHandlerFactory(new ContentHandlerFactory() {
public ContentHandler createContentHandler(String type) {
if (type.startsWith("text/x-omf"))
return new OMFHandler();
return null;
}
});
cx.setDoInput(true);
cx.setDoOutput(true);
cx.setAllowUserInteraction(false);
DataOutputStream os =
new DataOutputStream(cx.getOutputStream());
System.out.println("Connecting the URLConnection");
cx.connect();
System.out.println("Request is:");
System.out.println(request);
System.out.println("Sending Request");
os.writeBytes("mbl-stmt=" + URLEncoder.encode(request));
os.flush();
System.out.println("Getting the Response");
Object response = cx.getContent();
if (response instanceof InputStream)
response = FileIO.inputStreamToString((InputStream)response);
System.out.println(response);