兄弟,现在概念不太清楚。当然的先问清楚。
如果可以的话,那发送到客户端的只是applet的代码,
例如有一个数据项是用户可写的。我就的取出数据项中的数据放到输出流中。同时为客户端的applet添加text框。并将那些数据放在text显示(可以让客户修改)
可以使用代码text mytext=new text()。
将上面的代码发送到客户端,客户端可以正常显示马,哪样的代码可没有经过编译呀

解决方案 »

  1.   


    applets site:
     private void defineOrgStruc(ArrayList levellist) throws MalformedURLException, IOException{
        URL url = new URL(servleturl);
        URLConnection con = url.openConnection();
        con.setUseCaches(false);
        System.out.println(levellist.toString());
        try{
            ObjectOutputStream outputToServlet = null;
            con.setDoOutput(true);
            outputToServlet = new ObjectOutputStream(con.getOutputStream());
            outputToServlet.writeObject(levellist);
            outputToServlet.flush();
            outputToServlet.close();
           }catch (IOException se){
            JOptionPane.showMessageDialog(null, "Can not establish connection to server", "Connection failed", JOptionPane.PLAIN_MESSAGE);
            return;
          }    try{
            InputStream in = con.getInputStream();
            ObjectInputStream objStream;
            objStream = new ObjectInputStream(in);
            objStream.readObject();
        }catch(Exception re){
          JOptionPane.showMessageDialog(null, "Can not establish connection to server", "Connection failed", JOptionPane.PLAIN_MESSAGE);
          return;
        }
        JOptionPane.showMessageDialog(null, "Structure is saved!");
     }
      

  2.   

    servlet site:
    public class SaveOrgStrucServlet extends HttpServlet {
      private static final String CONTENT_TYPE = "text/html";
      //Initialize global variables
      public void init() throws ServletException {
      }
      //Process the HTTP Get request
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>SaveOrgStrucServlet</title></head>");
        out.println("<body>");
        out.println("<p>The servlet has received a GET. This is the reply.</p>");
        out.println("</body></html>");
      }
      //Process the HTTP Post request
        public void doPost(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException, ServletException{
                 System.out.println("Trying to save levels:");          ObjectInputStream inputFromApplet = null;
              BufferedReader inTest = null;
            try{
                inputFromApplet = new ObjectInputStream(request.getInputStream());
                ArrayList levelnamelist = (ArrayList)inputFromApplet.readObject();
                ModelForecastData obj = new ModelForecastData();
                obj.createOrgStucture(levelnamelist);
                //CreateOrgStrucXML xmlobject =new CreateOrgStrucXML(levelnamelist);             ObjectOutputStream servout = new ObjectOutputStream(response.getOutputStream());
                 servout.writeObject("done");
                 servout.flush();
                 servout.close();
              }catch(Exception se){
                 System.out.println(se.getMessage());
              }
    }
      //Clean up resources
      public void destroy() {
      }
    }
      

  3.   

    instead of using parameters to communicate, you should pass "object" between servlet and applet.
      

  4.   

    use tomcat for apache, www.org.apache, 
    it's free and easy to configure
      

  5.   

    hello soldier1002:
     
    you just only show the communication between servlet and Applet.
     but my problem is how to add controlbox such as jlabel,TextField and so on to client Applet from server.
     The code is not encoded .when client accept these .can the work well ?
     can you give me a hand or some advice .I will appreciate you  !