• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bypass proxy to access local network URLs

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much it worked great

Thanks for fast reply
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic