home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / app / web / WebPost.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  2.4 KB  |  83 lines

  1. package com.extensibility.app.web;
  2.  
  3. import com.extensibility.app.ApplicationPreferences;
  4. import java.io.BufferedReader;
  5. import java.io.IOException;
  6. import java.io.InputStreamReader;
  7. import java.io.PrintWriter;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10. import java.net.URLConnection;
  11. import java.net.URLEncoder;
  12. import java.util.Enumeration;
  13. import java.util.Hashtable;
  14.  
  15. public class WebPost implements Runnable {
  16.    String postLocation;
  17.    URL url;
  18.    ApplicationPreferences prefs;
  19.    URLConnection connection;
  20.    boolean successful = false;
  21.    Hashtable data;
  22.  
  23.    public void init(String var1, Hashtable var2, ApplicationPreferences var3) {
  24.       this.postLocation = var1;
  25.       this.data = var2;
  26.       this.prefs = var3;
  27.    }
  28.  
  29.    public void run() {
  30.       this.successful = false;
  31.  
  32.       try {
  33.          this.url = new URL(String.valueOf(this.postLocation).concat(String.valueOf("?")));
  34.       } catch (MalformedURLException var7) {
  35.          return;
  36.       }
  37.  
  38.       try {
  39.          this.connection = this.url.openConnection();
  40.          this.connection.setDoOutput(true);
  41.          PrintWriter var1 = new PrintWriter(this.connection.getOutputStream());
  42.          Enumeration var2 = this.data.keys();
  43.          Enumeration var3 = this.data.elements();
  44.  
  45.          while(var2.hasMoreElements()) {
  46.             var1.println(String.valueOf(String.valueOf(String.valueOf("&").concat(String.valueOf((String)var2.nextElement()))).concat(String.valueOf("="))).concat(String.valueOf(URLEncoder.encode((String)var3.nextElement()))));
  47.          }
  48.  
  49.          var1.close();
  50.          BufferedReader var4 = new BufferedReader(new InputStreamReader(this.connection.getInputStream()));
  51.  
  52.          String var5;
  53.          while((var5 = var4.readLine()) != null) {
  54.             if (var5.equalsIgnoreCase("true")) {
  55.                this.successful = true;
  56.             }
  57.          }
  58.  
  59.          var4.close();
  60.       } catch (IOException var8) {
  61.          this.successful = false;
  62.       }
  63.  
  64.       if (this.successful && this.prefs != null) {
  65.          this.prefs.put("RGS", "1");
  66.  
  67.          try {
  68.             this.prefs.save();
  69.          } catch (IOException var6) {
  70.          }
  71.       }
  72.  
  73.    }
  74.  
  75.    protected void finalize() {
  76.       this.connection = null;
  77.    }
  78.  
  79.    public boolean wasSuccessfull() {
  80.       return this.successful;
  81.    }
  82. }
  83.