というMain()
クラスのオブジェクトをシリアル化するクラスがありますNames
。を使用して を呼び出していApache HttpClient
ます。HttpPost()
servlet
public static void main(String[] args) {
Names names = new Names();
names.setName("ABC");
names.setPlace("Bangalore");
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("Name.txt"));
out.writeObject(names);
out.close();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://localhost:6080/HttpClientGson/FirstHttpPostServlet");
ObjectOutputStream
では、オブジェクトを送信するにはどうすればよいでしょうか。次の行を書きました
httppost.setEntity(out)
ただしsetEntity()
、型のオブジェクトしか取得できませんHttpEntity
。HttpClient
シリアル化されたオブジェクトを送信するために使用できる他の方法はありますか?