applet与SERLET交互...

String SERVURL = "Dispatch";
URL url;
URLConnection connect;
String ServletName;
OutputStream outs;
InputStream ins;
boolean outOpened;
boolean inOpened;
ServletName = SERVURL;
outOpened = false;
inOpened = false;

//open conn
url = new URL(Config.ServURL, ServletName);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setUseCaches(false); //for this one

//send stream
outs = connect.getOutputStream();
outOpened = true;
ObjectOutputStream out = new ObjectOutputStream(outs);
out.flush();
out.writeObject("request");
out.writeObject(PubProp.getSessionId());
out.writeObject(SendObjec);
out.close();


//reseiv
if (!inOpened) {
ins = connect.getInputStream();
inOpened = true;
}
ObjectInputStream in = new ObjectInputStream(ins);
ReciveObject obj = (GenericResponse) in.readObject();
in.close();

Powered by Zoundry

posted @ 2011-03-09 19:24  attilaxAti  阅读(26)  评论(0编辑  收藏  举报