I have simple POJO say User Object;
public class User{
private String userid;
private String emailid;
private String name;
....setters and getters...
}
Now,I want to set some values using setter methods of User class.
So,if i want to send this object to through service.
URL url = new URL("http://<servername>/example/someservice");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
what would be the best approach for this ?
Thanks in advance.
You need to convert your data (class instance) to bytes (it’s called serialization), send the bytes, and convert from bytes to data (it’s called deserialization).
Please try having a look at google
Some popular serialization options: in-built java serialization – binary, XML (text), JSON (text).