寫好jnlp,裡面配置好所依賴的jar的路徑
解决方案 »
- 注释一部分tomcat源代码,用tomcat执行刚刚web工程,结果要报错
- 服务器正常工作48小时后,突然挂了
- 高薪求WEB高级开发&CRM人才
- 谁能发本J2EE WITHOUT EJB给我
- 请问,启动tomcat后,用IE打开http://localhost:8080/JavaWebTest/后,出现404错误。
- 散分
- JBoss4.0.2 负载均衡集群配置!
- 向数据库里更新数据时出现的问题
- 上传文件时为什么read()读出的总是-1 呢?详情请进
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y
- 由于公司需要现在要弄台web服务器。。。。
- 请大家帮忙解答
HttpURLConnection connection = null; try {
URL serveletURL = new URL(你的url);
connection = (HttpURLConnection) businessServeletURL.openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "applicaiton/x-java-serialized-object");//可以传输POJO
ObjectOutputStream oos = new ObjectOutputStream(connection.getOutputStream());
oos.writeObject(dto);
oos.flush();
oos.close();
} catch (Exception e) {
e.printStackTrace();
}
ObjectInputStream ois = new ObjectInputStream(connection.getInputStream());
int status = connection.getResponseCode();
if (status >= HttpURLConnection.HTTP_OK &&
status <= HttpURLConnection.HTTP_MULT_CHOICE) {
Object obj = ois.readObject();
return obj;
} else {
错误处理 }
} catch (IOException e) {
e.printStackTrace(); } catch (ClassNotFoundException e) {
e.printStackTrace();
}
大概的意思就是这样,catch、finally可能有点问题,你把这玩意写出一个通用类在客户端就行了。
在servlet的doget和dopost里面 ObjectInputStream ois = new ObjectInputStream(request.getInputStream());然后进行处理 ObjectOutputStream os = new ObjectOutputStream(response.getOutputStream());
os.writeObject(你要发送的对象);
就可以了