0

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.

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.