0
私はアプレット---サーブレット通信を実装しています。アプレットがサーブレットに送る必要がある2つのパラメータがあります。次のように転送プロセスを実装することはできますか?そうでない場合、複数のパラメータを含む転送処理をどのように処理するのですか?ありがとう。アプレットとサーブレットの通信で複数のパラメータを転送する
アプレット側:
// send data to the servlet
URLConnection con = getServletConnection(hostName);
OutputStream outstream = con.getOutputStream();
System.out.println("Send the first parameter");
ObjectOutputStream oos1 = new ObjectOutputStream(outstream);
oos1.writeObject(parameter1);
oos1.flush();
oos1.close();
System.out.println("Send the second parameter");
ObjectOutputStream oos2 = new ObjectOutputStream(outstream);
oos2.writeObject(parameter2);
oos2.flush();
oos2.close();
サーブレット側は:(彼らは文字列値であるため)
InputStream in1 = request.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in1);
String receievedData1 = (String)inputFromApplet.readObject();
InputStream in2 = request.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in2);
String receievedData2 = (String)inputFromApplet.readObject();
あなたは[こちら](http://stackoverflow.com/questions/314300/how-to-simply-generate-post-http記載された技術を使用して見てきました-request-from-java-to-the-file-upload)? – aroth
そしてここにhttp://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests – BalusC
パラメータ間のObjectOutputStreamを閉じないでください。両方とも最初のObjectOutputStreamに渡します。 – MeBigFatGuy