Java implementation of get, post request