Blog Archive for January 8, 2010

Apache HTTPClient Get and Post

January 8, 2010

Here's examples of calling GET and POST requests using the Apache HTTPClient library

Performing a GET

This code performs a GET call:

HttpClient lClient = new HttpClient();
HttpMethod lMethod = new GetMethod(lUrlToCall);
int lCode = lClient.executeMethod(lMethod);
String lResponse = lMethod. …

Basic Servlet Reference

January 8, 2010

This post lists the basic code required to implement a Java servlet.

Handling GET requests

Create a method with the following signature:

public void doGet(HttpServletRequest pRequest, HttpServletResponse pResponse) 
                throws ServletException, IOException

Handling POST requests

Same as for GET, but with a different method name:

public …