Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bypass proxy to access local network URLs

 
Ashraf Fouad
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dears,
I have a web application deployed on application server Oracle 9i AppServer -I don't think the application server has

anything to do with my problem-, it calls other web application through HTTP, on the local network, the other application

servers are hosted on windows platform and/or Unix platform.

All these machine can access Internet through proxy server, but there are no proxy or firewalls between them, so everything

is openned between the machines in the local network.

When I try to connect from one machine to another using the following code, I find that it always request proxy

authentication, which I would like to bypass.
The error says: http request returned error code 407


package com.rsw.common.net;

import java.net.*;
import java.io.*;
import java.util.Properties;
public class UrlConnector
{
public void connect(String url,String[] params, String[] values )
{
try
{
URL l_URL = new URL(url);
URLConnection l_URLConnection = l_URL.openConnection();
l_URLConnection.setDoOutput(true);
l_URLConnection.setDoInput(true);
l_URLConnection.setUseCaches(false);
l_URLConnection.setRequestProperty("Method", "POST");
PrintWriter l_PrintWriter = new PrintWriter(l_URLConnection.getOutputStream());
String l_szParams ="";
if(params!=null)
{
if(params.length >=1)
l_szParams=params[0]+"="+URLEncoder.encode(values[0]);

for(int i=1;i<params.length;i++)
l_szParams+="&"+params[i]+"="+URLEncoder.encode(values[i]);

l_PrintWriter.println(l_szParams);
}
l_PrintWriter.close();
BufferedReader l_BufferedReader = new BufferedReader(new InputStreamReader(l_URLConnection.getInputStream()));
String l_szResponseLine = "";
String l_szURLResponse;
for ( l_szURLResponse = "";
(l_szResponseLine = l_BufferedReader.readLine()) != null;
l_szURLResponse = l_szURLResponse + l_szResponseLine );

l_BufferedReader.close();
System.out.println(l_szURLResponse);
}
catch(Exception l_exception)
{
System.out.println(l_exception.getMessage());
}
}
}


I found that what I need is similar to setting in Internet Explorer to bypass proxy for addresses starting with ..... But

I don't know how to apply this to my code? I'm using JDK 1.3.1

Anyone can help, I'm open to use any libary that overcome this problem.

Thanks, in advance
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the system property you're looking for is http.nonProxyHosts. You can find out more at...

http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
 
Ashraf Fouad
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much it worked great

Thanks for fast reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic