Creating a JSON post in Java
Here’s a simple bit of code to create a JSON post in Java…
URL url = new URL("http:://www.someUrl.com/someService");
String newRequest = "Whatever the Request you are trying to create is :)";
DefaultHttpClient httpClient = new DefaultHttpClient();
StatusLine responseStatusLine = null;
try {
HttpPost request = new HttpPost(url.toURI());
StringEntity params = new StringEntity(newRequest);
request.addHeader("content-type","text/plain");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
responseStatusLine = response.getStatusLine();
} catch (IOException e){
System.err.println(e);
} finally {
httpClient.getConnectionManager().shutdown();
}
What a great bios error!!
When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy’. They told me I didn’t understand the assignment, and I told them they didn’t understand life.
John Lennon
Ha brilliant!
Early morning on the luas
Sunset @ Lahinch Beach…october 2010
Page 1 of 5



