applet与SERLET交互...

来源:互联网 发布:数据库管理员工资待遇 编辑:程序博客网 时间:2024/04/29 19:51

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