Applet与Servlet通信的奇怪问题

tifaling 2003-08-22 10:20:11
Servlet:
void service(...,...)
{
DataOutputStream dos = new DataOutputStream(response.getOutputStream());
ObjectInputStream dis = new ObjectInputStream(request.getInputStream());
try
{
dis.readObject();
......
dos.writeInt(1);//返回成功
}
catch(Exception e)
{
dos.writeInt(0);//返回出错状态
}
}

Applet:
try
{
URL url = new URL(this.getCodeBase() + "servlet/setser");
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.connect();
ObjectOutputStream oos = new ObjectOutputStream(con.getOutputStream());
oos.writeObject(...);
DataInputStream dis = new DataInputStream(con.getInputStream());
int nRet = dis.readInt();
}
catch(Exception e)
{
......
}


现在有2个问题:
1。每次tomcat起动后Applet第一次运行这段程序是,servlet那里没有相应.以后就没有问题了
2。在Applet端int nRet = dis.readInt();老是被捕获(java.io.EOFException)
请各位帮忙!
...全文
36 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
beming 2003-08-29
  • 打赏
  • 举报
回复
4.1.27是最新的release版本!
tifaling 2003-08-29
  • 打赏
  • 举报
回复
jakarta-tomcat-4.0.6现在用这个,感觉比较稳定
aodlyf 2003-08-28
  • 打赏
  • 举报
回复
那就换个tomcat在测啊。
tifaling 2003-08-28
  • 打赏
  • 举报
回复
初步原因是我那个版本的tomcat不稳定,至少resin好像没有这个问题
indeed 2003-08-22
  • 打赏
  • 举报
回复
up.......

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧