Apache HTTPClient with JSF page (Specifically Geoportal)
===

OK, so I am trying to use Apache HTTPClient to post data to a JSF Page. If anyone has ever used Geoportal it is the harvester creation page. Anyways, I use a get request to get the page and then a post request with all the parameters required including the JSF view state parameter that was parsed out of the get request. When calling the POST request the page is returned but no actions were performed, such as saving the new harvester. Below is my code and any help would be greatly appreciated. Thanks.

    	HttpMethod getReq = new GetMethod(pageURI);
		getReq.addRequestHeader("Content-Type", "text/html");
		getReq.addRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1");
		getReq.addRequestHeader("Connection", "keep-alive");
		getReq.addRequestHeader("Cookie", "iPlanetDirectoryPro=" + token + "; JSESSIONID=" + sessionid);
		try {
			// Get the edit harvester page.
			int response = client.executeMethod(getReq);
			if(response != 200) {
				logError(responseObj, response + " error occured while trying to get the Harvester Edit page.");
				return responseObj;
			}
			String responseBody = new String(getReq.getResponseBody(), "UTF-8");
			getReq.releaseConnection();

			// Extract the View State value.
			int position = responseBody.indexOf("javax.faces.ViewState");
			if(position == -1) {
				logError(responseObj, "Unable to authenticate user. Please make sure your session has not expired.");
				return responseObj;
			}
			responseBody = responseBody.substring(position);
			int valPosition = responseBody.indexOf("value");
			String valString = responseBody.substring(valPosition + 7, valPosition + 60);
			facesValue = valString.substring(0, valString.indexOf("\""));
			System.out.println("Faces View: " + facesValue);
		}
		catch (HttpException e) {
			logError(responseObj, "Invalid HTTP retured while trying to get the Harvester Edit page.");
			return responseObj;
		}
		catch (IOException e) {
			logError(responseObj, "Unable to get the Harvester Edit page.");
			return responseObj;
		}

		// Build Post Request
		PostMethod postReq = new PostMethod(pageURI);
		postReq.addRequestHeader("Content-Type", "text/html");
		postReq.addRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.50215;)");
		postReq.addRequestHeader("Accept-Charset", "Chareset+\";q=0.7,*;q=0.7");
		postReq.addRequestHeader("Cookie", "iPlanetDirectoryPro=" + token + "; JSESSIONID=" + sessionid);
		String userDN = PropertiesService.getProperty("openldap.usersDN");
		NameValuePair data[] = {
				new NameValuePair("harvestCreate:hvSubmit", "Save"),
				new NameValuePair("javax.faces.ViewState", facesValue)
            // Note there are many more values here. I just removed them because they should serve no purpose.

		};
		postReq.setRequestBody(data);
		try {
			// Get the edit harvester page.
			int response = client.executeMethod(postReq);
			if(response != 200) {
				logError(responseObj, response + " error occured while trying to get the Harvester Edit page.");
				return responseObj;
			}
			String responseBody = new String(postReq.getResponseBody(), "UTF-8");
			postReq.releaseConnection();
		}
		catch (HttpException e) {
			logError(responseObj, "Invalid HTTP retured while trying to get the Harvester Edit page.");
			return responseObj;
		}
		catch (IOException e) {
			logError(responseObj, "Unable to get the Harvester Edit page.");
			return responseObj;
		}

