能说点详细点吗?
小弟是初学
小弟是初学
解决方案 »
- JS获取table中的td Object问题
- js权威指南上获取dom结点下的所有文本?诸位帮我看看
- 兼容问题
- 如何FireFox下实现IE的showModalDialog的功能?
- 如何控制文本输入框中只能输入数字文本下划线和连接线?
- 用javascript如何实现这样滴功能?应该很简单,想听听大家的思路!在线等!
- 能否给页面中的一个iframe定义事件?
- 请问用Javascript怎样在新敞口中建立链接?
- 简单的问题但是我不懂,谁帮我解决我愿意再送他500分!!!!!
- 在Netscape 6下怎么写?form1.elements[0].value="aaa"?
- 请教关于IFRAME.SRC更改不显示的问题
- 关于弹出窗口自动关闭的问题!!
* Get a connection to the servlet.
*/
private URLConnection getServletConnection()
throws MalformedURLException, IOException { URL urlServlet = new URL(baseurl, "/echo");
System.out.println(urlServlet);
HttpURLConnection con = (HttpURLConnection) urlServlet
.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type",
"application/x-java-serialized-object");
return con;
} /**
* Send the inputField data to the servlet and show the result in the
* outputField.
*/
private String onSendData(UpFile upfile) {
try {
// send data to the servlet
URLConnection con = getServletConnection();
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(upfile.getFile());
oos.writeObject(upfile.getFilePath());
oos.flush();
oos.close(); // receive result from servlet
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(
instr);
String result = (String) inputFromServlet.readObject();
inputFromServlet.close();
instr.close();
return result;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("bad");
return null;
}
}这个就是我最近的项目中用到的applet和servlet通信的两个method 你可以学着照做