和传变量有很大区别吗???String型变量,不也就是个String对象吗??

解决方案 »

  1.   

    applet和servlet传递参数使用ObjectOutputStream就行了
      

  2.   

    我知道你的意思,假如我的applet中有100个字符要传到servlet中,我先自定义一个类FlowView(FlowView view=new FlowView()),然后将这100个字符先写到类里,想在applet中将flowview对象View传到servlet中去。那怎么实现呢?
      

  3.   

    这些对象必须序列化,给个文档:http://www.j-nine.com/pubs/applet2servlet/Applet2Servlet.html
      

  4.   

    我将我的发送applet和接受servlet写出来,你们帮我看看!谢谢!=================sendToServlet=========================
    void b_actionPerformed(ActionEvent e) {
        URL url;
        URLConnection urlc;
        String chatURL="http://localhost:7001/acceptservlet";
        try{
          url=new URL(chatURL);
          urlc=url.openConnection();
          urlc.setDoInput(true);
          urlc.setDoOutput(true);
          urlc.setUseCaches(false);
          urlc.setRequestProperty("Content-type","application/octet-stream");
          urlc.setAllowUserInteraction(false);
          urlc.connect();
          //写入对象
         ObjectOutputStream objectout = new ObjectOutputStream(urlc.getOutputStream());
         Vector tmpv = new Vector();
         FlowView view=new FlowView();
         view.SetName("wjg");
         view.SetName1("jlh");
         tmpv.add(view);
         objectout.writeObject(tmpv);
         objectout.close();
        }
        catch(UnsupportedEncodingException e){
          System.out.print("caught a UnsupportedEncodingException");
        }catch(MalformedURLException e2){
          System.out.print("caught a MalformedURLException");
        }
        catch(IOException e1){
          e1.printStackTrace(System.err);
        }
      }
    ====================acceptServlet=======================
     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("application/octet-stream");
        Vector result = null;
        ObjectInputStream in=null;
          try {
            in = new ObjectInputStream(request.getInputStream());
            result = (Vector) in.readObject();
            in.close();
          }
          catch (Exception e) {
            System.out.println("目前还没有对象");
          }
          try {
              SubmitBean bean=new SubmitBean();
              int a=result.size();
              for(int i=0;i<a;i++){
               FlowView aaa = (FlowView) (result.elementAt(i));
               bean.add(aaa);//这是个JAVABEN,功能是向数据库插入数据
          }
          catch (SQLException eee) {
            System.out.print("无法插入数据库");
          }
      }他就是插不进去内容。
      

  5.   

    我知道要序列化的,我从servlet向applet发送对象已经弄出来了,但从applet向servlet发送对象却老是不成功!望各位大虾能耐心指点,谢谢!
      

  6.   

    lvyuanfang() ,我先侃侃你提供的文档,然后一定会揭贴的!谢谢!