1  import java.awt.*;
  2  import java.net.*;
  3  import java.io.*;
  4  import java.lang.String;
  5  
  6  public class ex extends java.applet.Applet {
  7  
  8    TextArea ta = new TextArea();
  9    TextField status = new TextField("Please type below",40);
 10    Button button = new Button("Write to Server");
 11  
 12    public void init() {
 13      setLayout(new BorderLayout(20,20));
 14      add("North",status);
 15      add("Center",ta);
 16      add("South",button);
 17    }
 18  
 19    public boolean action(Event evt, Object arg) {
 20      if(evt.target instanceof Button) {
 21        String text_entered = ta.getText();
 22        
 23        String sdata;
 24        sdata = "ta=" + text_entered;
 25        
 26        status.setText("Processing Request . . .");
 27        String home = "osprey7.npac.syr.edu";
 28        String script = "/users-cgi/mispirli/write.pl";
 29        int port = 3768;
 30        Socket s = null;
 31        try {
 32  	s = new Socket(home,port);
 33  	DataOutputStream os = new DataOutputStream(s.getOutputStream());
 34  	DataInputStream is = new DataInputStream(s.getInputStream());
 35  	os.writeBytes("POST " + script
 36  		      + " HTTP/1.0\r\n"
 37  	      //+ "Content-type: application/x-www-form-urlencoded\r\n"
 38  		      + "Content-type: text/plain\r\n"
 39  		      + "Content-length: " + sdata.length() + "\r\n\r\n");
 40  	status.setText("Stuff set to machine");
 41  	os.writeBytes(sdata);
 42  	
 43  	is.close();
 44  	os.close();
 45        }
 46        catch (Exception e)
 47  	{
 48  	  showStatus("Error " + e);
 49  	  status.setText("Errors!!!");
 50  	  if (s != null)
 51  	    try {
 52  	      s.close();
 53  	  }
 54  	  catch(IOException ex) {}
 55  	}
 56        status.setText(sdata);
 57        return true;
 58      }
 59      else return false;
 60    }
 61  }  
 62  
 63  
 64  
 65        
 66