我在applet写了这样的方法,可是我的servlet就是没有反应,java控制台也不报错,怎么回是?void outputServlet(String message){
          try{
          String temp_sServerName = "localhost:8080";
          String location ="http://" + temp_sServerName + "/chip/servlet/chipServlet?message="+message+"";
          java.net.URL chipServlet = new URL(location);
          java.net.URLConnection servletConnection = chipServlet.openConnection();
          // konfigurieren
          servletConnection.setDoInput(true);
          servletConnection.setDoOutput(true);
          servletConnection.setUseCaches(false);
          servletConnection.setRequestProperty(
                "Content-Type",
                "application/x-java-serialized-object");          servletConnection.connect();
          OutputStream opStream = servletConnection.getOutputStream();
          ObjectOutputStream   oisToServlet = new ObjectOutputStream (opStream);
          oisToServlet.writeObject(message);
          oisToServlet.flush();//把在输出流中的东西输出
          oisToServlet.close();
      }
      catch(Exception ex){
         ex.printStackTrace();
      }
  
        }
在浏览器输入"http://" + temp_sServerName + "/chip/servlet/chipServlet?message="+message+"";,servlet可以运行

解决方案 »

  1.   

    try{
              String temp_sServerName = "localhost:8080";
              String location ="http://" + temp_sServerName + "/chip/servlet/chipServlet?message="+message+"";
              java.net.URL chipServlet = new URL(location);
              java.net.URLConnection servletConnection = chipServlet.openConnection();
    OutputStream opStream = servletConnection.getOutputStream();
              ObjectOutputStream   oisToServlet = new ObjectOutputStream (opStream);
    }
    改成这样试试