社区
Web 开发
帖子详情
有关Applet和Servlet通讯的怪事。
hurt75
2001-11-30 10:46:56
当Applet发字符串给Servlet的时候,我flush 了close了,但我再按一次Applet的发送的话,为什么Servlet收到的确实是二个串加在一起呢?比如我发送了“abcde”,当再按一次Applet发送的时候却收到了"abcdeabcde"是二串想加,Servlet的out每次也close了,就是不行,反正是按一次串就再加一次,奇怪,请问这是怎么回事?
...全文
170
3
打赏
收藏
有关Applet和Servlet通讯的怪事。
当Applet发字符串给Servlet的时候,我flush 了close了,但我再按一次Applet的发送的话,为什么Servlet收到的确实是二个串加在一起呢?比如我发送了“abcde”,当再按一次Applet发送的时候却收到了"abcdeabcde"是二串想加,Servlet的out每次也close了,就是不行,反正是按一次串就再加一次,奇怪,请问这是怎么回事?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
javamap
2001-12-01
打赏
举报
回复
I believe both Applet and Servlet works correctly. The problem is in your code after Servlet receiving.
xpxxp
2001-12-01
打赏
举报
回复
管道流中数据不清除,请你改用SOCKET通信,如果你坚持做,你就只能让APPLET发,SERVLET收。管道的连接是单向的,如果你用这个连接发数据,你自己可以用输入流收下来。而SOCKET则不是他的连接是双向的。
dracowoo
2001-12-01
打赏
举报
回复
请讲清楚一些。。我还是不清楚。我的问题是这样的。当网页关掉的是时候就没有这个问题
。但是如果网页不关闭。譬如说在网页上有一个按钮。我第一次点击的时候。工作正常。如果我
点击两次以上的话。我在servlet的request接收的数据总是两个数据串ping在一起的。就是前一次送的串也存在。
到底是applet里设置联接的时候有什么问题吗?我的applet里面的方法代码如下
private void sendXMLStr() {
try {
URL codeBase = getCodeBase();
URL url =
new URL(
"http://"
+ codeBase.getHost()
+ ":"
+ codeBase.getPort()
+ "/servlet/com.cs.eximbills.RegisterServlet");
String xmlStr =
URLEncoder.encode("xmlStr") + "=" + URLEncoder.encode(XMLStr.toString());
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
//------------begin write the xml str to the outputStream----------------//
/*try {
PrintWriter out=PrintWriter(uc.getOutputStream());
//out.print(xmlStr+"="+URLEncoder.encode(XMLStr.toString()));
} catch (Exception e) {
System.out.println(e.toString());
}*/
try {
DataOutputStream dos = new DataOutputStream(uc.getOutputStream());
dos.writeBytes(xmlStr);
//dos.writeChars(xmlStr);
dos.flush();
dos.close();
} catch (Exception e) {
System.out.println("can't write to OutputStream");
}
//------------end write the xml str to the outputStream-------------------//
InputStreamReader in = new InputStreamReader(uc.getInputStream());
int chr = in.read();
while (chr != -1) {
//taResults.append(String.valueOf((char) chr));
chr = in.read();
}
in.close();
} catch (MalformedURLException e) {
System.out.println(e.toString());
} catch (IOException e) {
System.out.println(e.toString());
}
}我在servlet接收xmlStr这个值。谢谢
applet
与
servlet
通讯
如何实现java
applet
与
servlet
通讯
Applet
与
Servlet
之间的通信与交互
NULL 博文链接:https://self4j.iteye.com/blog/914068
applet
和
servlet
的
通讯
,并打印
applet
请求
servlet
,然后
servlet
读取文件流,并把文件流返回给
applet
,供
applet
打印
Applet
与
servlet
、数据库交互
材料列表: 1.
applet
数字签名 安全问题 2.
Applet
访问mysql数据库 3.
Applet
和
Servlet
利用http对象流通信 4.J2EE企业应用:
Applet
和
Servlet
的通信...等等
applet
+
servlet
+jsp描点
用
applet
+
servlet
+jsp根据MVC模式进行从数据库中取数据进行动态描点。
Web 开发
81,116
社区成员
341,738
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章