File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Unable to download word document hosted on Windows qshare from a Linux machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Unable to download word document hosted on Windows qshare from a Linux machine" Watch "Unable to download word document hosted on Windows qshare from a Linux machine" New topic
Author

Unable to download word document hosted on Windows qshare from a Linux machine

Bhaskar Kamuju
Greenhorn

Joined: Feb 12, 2010
Posts: 3
Hi,

I need to download a word document from a Windows/Microsoft qshare location using Java.

I use the following code to do that


This works perfectly fine when I run it from a windows machine.
But it throws an exeption "401- Unauthorized access" when I try to run this from a Linux machine.
java.io.IOException: Server returned HTTP response code: 401 for URL: http://qshare/sites/ib_coe/Footprint.doc
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon nection.java:1313)
at FileReaderTest.readFileFromServer(FileReaderTest.java:58)
at FileReaderTest.main(FileReaderTest.java:92)

Both the Linux machine and the qshare are in the same network, so I don't see any firewall issue here.

So, is there any other property I need to set?

Can anyone tell me how this can be resolved?

One more thing is when I try to open "http://qshare/sites/ib_coe/Footprint.doc" using Firefox, I keep getting an alert prompting for username/password, but I am not able to go in inspite of entering the username and password. Whereas in IE I can go directly in, it does some windows authentication and allows me to enter without prompting for username/password.



Thanks,
Bhaskar

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

One more thing is when I try to open "http://qshare/sites/ib_coe/Footprint.doc" using Firefox, I keep getting an alert prompting for username/password, but I am not able to go in inspite of entering the username and password.

This statement is the key! What are you using to host qshare? IIS? If so, how is the security configured in IIS? Is it using integrated Windows authentication (don't think that is the correct technical term, but I hope you get the idea)? If so, then running the code from Windows works because the OSes are swapping credentials (the credentials in your code are being ignored). If all of this is so, you need to modify how IIS is doing authentication. Only when you can access the document via Firefox by entering in the username/password will your Java code work.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to download word document hosted on Windows qshare from a Linux machine