日期:2014-05-18  浏览次数:20756 次

applet与servlet通信问题.
我建了一个非常简单的applet,怎么就和servlet通信不了那.servlet中接不到值.哪位帮看看

applet::

public   void   init()   {
JButton   jb=new   JButton( "OK ");
this.add(jb);
try   {
URL   url   =   new   URL( "http://localhost:8080/demo/servlet/myServlet?send_param=hello ");
URLConnection   connect   =   url.openConnection();
//   下次连接不用Cache
connect.setDefaultUseCaches(false);
//   这次连接也不用Cache
connect.setUseCaches(false);
//   打开淂流用于读数据
connect.setDoInput(true);
//   不能用于写数据
connect.setDoOutput(false);

//   服务器与客户的真正连接
connect.connect();
}catch   (Exception   e)   {
e.printStackTrace();
}

//   Put   your   code   here
}


------解决方案--------------------
这样的设置下,必须读数据,才能使得connect对象真正向url发出请求。