Topic: 高手帮忙:applet和servelet通信遇到的问题

  Print this page

1.高手帮忙:applet和servelet通信遇到的问题 Copy to clipboard
Posted by: whp320
Posted on: 2006-03-16 14:28

java.net.UnknownServiceException: protocol doesn't support output
  at java.net.URLConnection.getOutputStream(Unknown Source)

程序代码如下:
URL servletURL=new URL(this.getDocumentBase(),"queryServlet");
  URLConnection connection=servletURL.openConnection();
// System.out.println(connection.getAllowUserInteraction());
  System.out.print(connection.getAllowUserInteraction());
      connection.setUseCaches(false);
      connection.setDoOutput(true);
ByteArrayOutputStream byteStream=new ByteArrayOutputStream(1024);
  PrintWriter outf=new PrintWriter(byteStream,true);
  String postData="timeStr="+URLEncoder.encode(timeStr);
  postData+="Airtimes="+URLEncoder.encode(Airtimes);
      outf.print(postData);
      outf.flush();
      String lengthString=String.valueOf(byteStream.size());
      connection.setRequestProperty("Content-length",lengthString);
      connection.setRequestProperty("Content-Type","application/x-www-form-rulencoded");
      
      
      //这句报的错误!!!
      byteStream.writeTo(connection.getOutputStream());
      BufferedReader br=new BufferedReader(new InputStreamReader(connection.getInputStream()));
      String resultStr=br.readLine();

2.Re:高手帮忙:applet和servelet通信遇到的问题 [Re: whp320] Copy to clipboard
Posted by: whp320
Posted on: 2006-03-16 14:29


3.Re:高手帮忙:applet和servelet通信遇到的问题 [Re: whp320] Copy to clipboard
Posted by: bigbigpoo
Posted on: 2006-03-16 14:52

public class UnknownServiceException
extends IOException

Thrown to indicate that an unknown service exception has occurred. Either the MIME type returned by a URL connection does not make sense, or the application is attempting to write to a read-only URL connection.

4.Re:高手帮忙:applet和servelet通信遇到的问题 [Re: whp320] Copy to clipboard
Posted by: whp320
Posted on: 2006-03-16 16:02

我跟踪了this.getDocumentBase()的值。得到的是我的applet.htm。实际上,我是写成了applet.jsp的。这里的连接有问题。请问应该怎么办?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923