0

Hellow everyone,

I have this Java Method below. I used a link which requires authentication and when I ran this in Eclipse, it worked well.

validURL("http://localhost/context/myfile.pdf");

However, when I deployed this in Weblogic, the method returns an error which was " 401Unauthorized".

I tried this link but did not work:

validURL("http://username:password@localhost/context/myfile.pdf");

Can you please give me some suggestions regarding this?

Thanks in advance

private static boolean validURL(String docpath)
    {
        boolean fileExists = false;
        try
        {
            URL u1 = new URL(docpath);
            java.io.InputStream testStream = u1.openConnection().getInputStream();
            fileExists = true;
        }
        catch(IOException e)
        {
        	e.printStackTrace();
        }
        return fileExists;
    }
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by NormR1
0

Can you look at what the server receives when you try to access it with that URL?
What happens if you use that URL in a browser?

I don't know if the URL class has the logic to do the steps needed to respond to a 401 response by generating the Authorization: field in the HTTP response header.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.