APACHE COMMONS / CATATAN</>↗Apache Commons23 Jun 2009
This example demonstrate how to use PropertyUtils.setMappedProperty() method to modify a Map typed property value of a bean. To set the property we need to pass bean instance, property name, map key and map value to PropertyUtils.setMappedProperty() method. package org.kodejava.commons.beanutils; import org.apache.commons.beanutils.PropertyUtils; import org.kodejava.commons.beanutils.support.Track; import org.kodejava.commons.beanutils.support.Record; import java.util.HashMap...
APACHE COMMONS / CATATAN</>↗Apache Commons20 Jun 2009
In this example we show how to set the value of an indexed property. In the code below we modified the value of an array type. We’ll change the second colors of MyBean‘s colors property. We do it in the same way as we are using the PropertyUtils.setSimpleProperty method. For indexed property we use the […]
APACHE COMMONS / CATATAN</>↗Apache Commons15 Jun 2009
The Commons BeanUtils component provides a class called PropertyUtils that supplies method for manipulating a bean such as our Track class below. For this demo we use a Track class that have a property called id, title and duration. To set the value of a bean we can use the PropertyUtils.setProperty() method. This method ask […]
APACHE COMMONS / CATATAN</>↗Apache Commons05 Des 2008
To send query string information in HTTP GET command you either using passing a simple string or an array of NameValuePair object into the HttpMethod‘s setQueryString() method. We also need to encode the parameter values before passing it to the method. package org.kodejava.commons.httpclient; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.util.URIUtil; import org.apache.commons.httpclient.methods.GetMethod; import java.io.IOException; public cla...
APACHE COMMONS / CATATAN</>↗Apache Commons04 Des 2008
In this example you will see how to configure proxy when using the Apache Commons HttpClient library. package org.kodejava.commons.httpclient; import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache....
APACHE COMMONS / CATATAN</>↗Apache Commons30 Nov 2008
Below is an example using Commons HttpClient library to retrieve information from a website using HTTP GET method. The response will be returned as stream by the HttpMethod.getResponseBodyAsStream() method. If you want something simple you can get the response as string by using the HttpMethod.getResponseBodyAsString() method. package org.kodejava.commons.httpclient; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; import org.a...