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;
}