• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble in accessing URL (firewall restriction)  RSS feed

 
Sourav Ken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write small code to access URL. Trouble is I am able to do it from browser but not from Java code. I can see browser setting and there is nothing much apart from Automatic proxy configuration URL.
In Firefox --> Tool -->options --> Advanced --> Network --> Connection --> Setting --> Automatic proxy configuration URL,
Basically whatever request we are sending is going via this proxy URL
Is there way we can use this proxy configuration URL in Java so Browser like capabilities can be achieved.
I am sure this is not new problem hence I am even fine with link to the already answered post. Please suggest.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check if either of the two approaches mentioned in https://www.coderanch.com/how-to/java/AppletsFaq#proxy work.
 
Sourav Ken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks. I am sure I am missing something here but in the JAVA applet I can find in the control panel I provided the script details there but still no response.

But URL that is configured in the browser is the

http://xyz.com/default.pac

As I mentioned earlier this is the reason I am able to browse net.

Now trouble is this file is having all the different IP address and all. Just wondering if there is any API which can read this URL and decide what to do with the request and response.

I m not sure if I make sense or make the problem more complex.
 
Sourav Ken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good news. now I am able to get the response. But what still amazes me what is it happening behind the scene, I believe it will be worth knowing...
What I did is I use API called Proxy-vole. If it will help anybody please visit below url where I find the solution.
solution

Now Java code

This class is using Proxy-Vale API Which I use in my main class



This is mine main class. Please see line number 29 where I have confusion on its working.

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please stop using so much color in your post. It makes it unpleasant to read. If you want people's help, you should be making it easy for them to read your posts, not hard. Colors, bold, etc. should be used sparingly and only for emphasis or association, not for full paragraphs or posts.

Thanks.
 
Sourav Ken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your inputs Jeff. I don't know if the post can be edited now, but in future I will try not to use multiple colors.
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sourav Ken wrote:// What is happening here Because after introducing these lines My code started to work.

Proxy-Vole search for current client proxy settings from all common sources. For example Firefox:

If it finds it configures java.net.ProxySelector to use the settings to access external resources.
You can find more details in source code.
 
Sourav Ken
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Surlac. I have not gone there so far to satisfy my curiosity as I am stuck in another problem here. Still banging head to look for the solution.

As per my Last my post I am getting the response. Next challenge is to get the response for the attribute and value in the URL. I have tried couple of ways but somehow it’s not going anywhere.

Problem Statement:

I have form in a webpage that I want to populate using java code and submit. In response I will get the same webpage with some data related to inputs like current time, date, user name entered in the form etc.
In the form there are some input data of type hidden fields. And I am not sure of the significance but I also see one input hidden field outside the form.

Challenge:

I am getting success in hitting the url and getting the response but I am not getting success in passing the fields. Its from with post method.
I tried HTTP client it keep coming back with
“java.net.SocketException: Unknown proxy type : HTTP”

Other options somehow sending wrong info to URL which redirecting me to Error page

Any suggestion from where I should start.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!