• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Get Response Code 200 in windows but get Response Code 401 on Unix

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Program simply connects to a server and gets back the response from the website.
It is working fine under the Windows XP env. (Response Code: 200, Response Message: OK) but when the same code is run on the
Unix m/c it connects to the website but gets a negative response (Response Code 401, Response Message Unauthorized).

I am using instance of class HttpURLConnection.
There are differences in the versions of java used in both the enviornments.

Win
----
java full version "1.5.0_14-b03"

Unix
-----
java full version "1.4.2_06-b03"

In Unix I tried to ping the website using the ping command.

ping <website>
<website> is alive

Also tried to setting proxy server which my web browser was using in windows

System.getProperties().put("proxySet","true");
System.getProperties().put("proxyPort","8080");
System.getProperties().put("proxyHost","10.196.51.140");

It didnt help either. Is there some Unix enviornment related setting which can be configured in Java.
Kindly advise
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the proxy require authorization (a username and password)? If yes, then you'll need to set the proxy username and password as well, otherwise the proxy server will tell you you're not authorized.

You can find examples on the web on how to do that:
http://www.rgagnon.com/javadetails/java-0085.html
http://www.javaworld.com/javaworld/javatips/jw-javatip42.html
 
ABHINAV KUMAR
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jasper
So I believe its the Proxy server which responds with code 401 , Unauthorized and not the actual website ?
Will get & try using the credentials of the proxy server.
 
ABHINAV KUMAR
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will it be worth wile to check the headers of the request going from the Unix m/c to the website,
Assuming the website server returns Response code 401 on the basis of the information sent to it in header ?
 
ABHINAV KUMAR
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'snt there a solution for this ?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BeForthrightWhenCrossPostingToOtherSites
http://forums.sun.com/thread.jspa?threadID=5446092
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic