Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4073348

rfe: Missing properties for proxy server support in URL-classes.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.0.2
    • docs
    • None
    • beta3
    • x86
    • windows_nt



      Name: joT67522 Date: 08/20/97


      Dear Sirs,
      I have a simple problem: retrieving data from a web-server via a
      proxy-server from within an applet. There are no properties for
      proxy support in classes URL, URLConnection,... How can I set proxy
      parameters in an applet? I tried the following example, but it didn't
      work:

      <begin
      import java.awt.*;
      import java.applet.*;
      import java.io.*;
      import java.net.*;

      public class URQ2 extends Applet {

      public void init() {
      super.init();

      //{{INIT_CONTROLS
      setLayout(null);
      addNotify();
      resize(426,266);
      setBackground(new Color(12632256));
      textUrl = new java.awt.TextField();
      textUrl.reshape(24,12,382,26);
      add(textUrl);
      textArea = new java.awt.TextArea();
      textArea.reshape(24,48,379,193);
      add(textArea);
      //}}
      }

      public boolean handleEvent(Event event) {
      return super.handleEvent(event);
      }

      public boolean action(Event e, Object o) {
              if (e.target == textUrl) {
                  URL baseu;
                  URL u;
                  try {
                      baseu = new URL("http://140.13.8.220:8080/");
                  }
                  catch (MalformedURLException me) {
      textArea.appendText("Malformed baseURL: http://140.13.8.220:8080/");
                      return true;
                  }
                  
                  try {
                      
      u = new URL(baseu, textUrl.getText());
           /*URLConnection connection = u.openConnection();
           PrintStream outStream = new PrintStream(connection.getOutputStream());
                      outStream.println("GET http://www.microsoft.com/ HTTP/1.0" + "\n");
                      outStream.close();
      */
                      DataInputStream inStream = new DataInputStream(new BufferedInputStream(u.openConnection().getInputStream()));
                      String inputLine;

                      while ((inputLine = inStream.readLine()) != null) {
                          textArea.appendText(inputLine);
                      }
                      inStream.close();
      }
      catch(MalformedURLException me) {
          textArea.appendText("Malformed URL: " + me.toString());
      }
      catch(IOException ioe) {
                      textArea.appendText(ioe.toString());
      }
      return true;
              }
      else
      return false;
          }
          
      //{{DECLARE_CONTROLS
      java.awt.TextField textUrl;
      java.awt.TextArea textArea;
      //}}
      }
      end>

      In VisualBasic I have a control with proxy properties and it works fine.

      I'm very interested about your answer!

      Yours very truly

      Helmut Frankenbach
      company - SIEMENS AG , email - ###@###.###
      ======================================================================

            shommel Scott Hommel (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: