• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
ABHINAV KUMAR
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
I'snt there a solution for this ?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BeForthrightWhenCrossPostingToOtherSites
http://forums.sun.com/thread.jspa?threadID=5446092
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!