Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IE4 behind a proxy server

Posted on 1998-05-22
10
Medium Priority
?
364 Views
Last Modified: 2010-08-05
I have an applet that uses http to communicate to a process running on its host.  This applet works fine when not behind a  firewall, and I know how to configure Navigator 4 so that it does not prevent the applet from communicating when run behind a firewall.

How can I convince IE 4 to allow the http connection?

The proxy forces a DNS lookup which violates an applet security requirment.  Netscape has a technique for avoiding this, does Microsoft?
0
Comment
Question by:gerry99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1221370
How is your APPLET accessing the remote host?  Is it using "raw" java.net.Socket calls or java.net.URLConnection?  If using Socket, then you must determine if a proxy is present and talk to the proxy yourself.  If using URLConnection, the library will detect your proxy setting by itself and talk through the proxy as needed.
0
 
LVL 1

Author Comment

by:gerry99
ID: 1221371
I'm currently using Socket, because I want to use the CGI Post format.

Some code:

      // get name of html data page
      String sQuery = "POST " + m_source + " HTTP/1.0\r\n"
            + "Content-type: application/x-www-form-urlencoded\r\n"
            + "Content-length: " + m_content.length() + "\r\n\r\n"
            + m_content;
              try       
      {
            // open a socket - m_host set to documentBase, port = 80
            sock = new Socket( m_host, m_port );
            // get data streams
            outStrm = new DataOutputStream( sock.getOutputStream() );
            inStrm = new DataInputStream( sock.getInputStream() );
            // send the request
            outStrm.writeBytes( sQuery );
            // read the page
            while( (line = inStrm.readLine()) != null )
                     // do something with response


0
 
LVL 32

Accepted Solution

by:
jhance earned 800 total points
ID: 1221372
If you're using Socket, you have to use some type of setting to tell your applet to talk to/through the HTTP proxy instead of directly to the remote system.  Basically everything is the same except the following:

1) Instead of opening a Socket to the remote server, you open a Socket to the proxy server and it's port.

2) The HTTP is the same except that you put the full URL (i.e. http://www.remote.com/page.html) where you would normally put just /page.html.

The proxy will do what you ask for you and you will get a response back from the proxy as though you were talking directly to the remote server.
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 1

Author Comment

by:gerry99
ID: 1221373
Do I need to determine the url of the proxy? and its port?
How would I do that?

In your point 2)
My socket is opened using the full URL of the applet's originating host.  I'm not using
partial URLs here.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1221374
You need to ask your firewall/proxy administrator what the address and port of the proxy are.  If your web browser works, it seems to me that you must already know it.

Your m_source is normally just the page or script you want at the host.  Something like /page.html.  When talking to a proxy, you give the proxy the full URL of what you want.  So in your example, m_source would be something like:

http://www.remote.com/page.html:80

0
 
LVL 1

Author Comment

by:gerry99
ID: 1221375
jhance,

I'm going to take some time, to see if I can implement my
http based query using a URLConnection.  I'll get back to you.

The applet in question is available on the public internet, and
can be accessed by people behind firewalls and proxies that I've
never heard of, and that I can't encode into my applet.  I suppose I could prompt for proxy information, but that is too technical for the audience I'm targetting.

The root of my frustration is that connecting back the the host, is well within the sandbox requirements, and yet it can fail based on external networking considerations, and browser type.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1221376
Again, that's the purpose of the URLConnection.  It uses the browser's setup to connect either directly or via a proxy if that's what is configured.  If the browser isn't setup right, then it's a mute point as the user won't ever get to your applet to begin with.  The Socket class is a lower level class that gives you (the programmer) more control over the connection.
0
 
LVL 1

Author Comment

by:gerry99
ID: 1221377
I've created some code that uses the URLConnection.  I'm still waiting to find out if this fixes the proxy problem.

During testing I've noticed that the connection.getOutputStream" throws an exception with Netscape 4.05 (JDK 1.5 preview version).

This is my code:

url = new URL( "http", m_host, m_port, m_source );
connection = url.openConnection();
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-length", Integer.toString(m_content.length()) );
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches( false );
connection.connect();

outStrm = new DataOutputStream( connection.getOutputStream() );
outStrm.writeBytes( m_content );
outStrm.flush();
outStrm.close();

inStrm = new DataInputStream( connection.getInputStream() );
// read the response                  String line;
while( (line = inStrm.readLine()) != null )
{
     // do something
}

This is the exception:
# Applet exception: Already connected
java.lang.IllegalAccessError: Already connected
  at java.lang.Throwable.<init>(Compiled Code)
  at java.lang.Error.<init>(Compiled Code)
  at java.lang.LinkageError.<init>(Compiled Code)
  at java.lang.IncompatibleClassChangeError.<init>(Compiled Code)
  at java.lang.IllegalAccessError.<init>(Compiled Code)
  at netscape.net.URLConnection.getOutputStream(Compiled Code)
* at sw.common.data.Preferences.MakeQuery(Compiled Code)
  at sw.common.data.Preferences.run(Compiled Code)
  at java.lang.Thread.run(Compiled Code)
java.io.IOException: CreateProcess: vcafe -netscape error=2
  at java.lang.Win32Process.<init>(Compiled Code)
  at java.lang.Runtime.exec(Compiled Code)
* at java.lang.Runtime.exec(Compiled Code)
  at netscape.debug.Debugger.launchDebugger(Compiled Code)
  at netscape.debug.Debugger.uncaughtException(Compiled Code)
  at netscape.applet.AppletThreadGroup.uncaughtException(Compiled Code)

IllegalAccessError is normally thrown if the runtime libary has
changed method or variables in an incompatible way.

From my documentation:
"Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.

Normally, this error is caught by the compiler; this error can only occur at run-time if the definition of a class has incompatibably changed. "

The code above works fine with IE 4.

Any suggestions?
0
 
LVL 1

Author Comment

by:gerry99
ID: 1221378
Jhance,

I've had a client test my new code using URLConnection instead of
Socket, with IE4, behind a firewall/proxy and apparently it still fails.  I'm not sure of the exact nature of the failure.

I'm prepared to accept your answer if you can clarify the following.  A URLConnection will use whatever proxy setup the user has encoded in their browser.  Is this correct?  If so then by definition any applet loaded from the internet that uses URLConnection should be able to communicate back to its host using a fully specified URL (http://myhost.com/myCGI) and the URLConnection.

BTW, with the last exception, I discovered the Netscape and MS both work fine if you remove the "connection.connect();" line.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1221379
I don't find the connect() method as one listed in the URLConnection class.  I'm looking at the JDK 1.02 docs but I don't see it.

A URLConnection when run in a applet within IE or Navigator will use the proxy settings of the host browser environment. This is the exception to the Java applet security rule where the only network connections an applet can make are back to the server which served up the applet.


0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question