gunacesun
asked on
How do I access a PDF file on the Unix server from my browser running on Windows XP
I display the name of the file on the browser and when the user clicks on the name, I want to display the file.
What I've tried:
I have created a URI from a Java File object. The URI looks like \\\\comp1\public\test\2008 \06\file1. PDF (It only has 4 \'s at the beginning of the URI). When I click on the link nothing happens. If the URI has 5 \'s in the beginning it works.
How do I fix this?
Or is there a better/differnt way to do this?
TIA,
Ganesh.
What I've tried:
I have created a URI from a Java File object. The URI looks like \\\\comp1\public\test\2008
How do I fix this?
Or is there a better/differnt way to do this?
TIA,
Ganesh.
ASKER
Thanks for the reply CEHJ.
But when I said "I have created a URI from a Java File object." in my original post, I used the File.toURI method since File.toURL has been deprecated.
But when I said "I have created a URI from a Java File object." in my original post, I used the File.toURI method since File.toURL has been deprecated.
> , I used the File.toURI method since File.toURL has been deprecated.
Thats corect, don't use toURL
How exactlky are you using it?
Thats corect, don't use toURL
How exactlky are you using it?
>>I used the File.toURI method since File.toURL has been deprecated.
Yes, sorry - forgot about that. In that case you can do
file.toURI().toURL()
Yes, sorry - forgot about that. In that case you can do
file.toURI().toURL()
ASKER
CEHJ:
I've already tried file.toURI().toURL(), and the value returned is same as file.toURI().
objects:
I have a File object and I get the uri by using the method File.toURI(). Hope this answers your question.
I've already tried file.toURI().toURL(), and the value returned is same as file.toURI().
objects:
I have a File object and I get the uri by using the method File.toURI(). Hope this answers your question.
Please post your code
ASKER
Here is the code snippet:
File file = (File) getCurrentRowObject();
URI uri = null;
URL url = null;
uri = file.toURI();
try {
url = uri.toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("uri: " + uri);
System.out.println("url: " + url);
return "<a href=" + url + " >Open file</a>";
File file = (File) getCurrentRowObject();
URI uri = null;
URL url = null;
uri = file.toURI();
try {
url = uri.toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("uri: " + uri);
System.out.println("url: " + url);
return "<a href=" + url + " >Open file</a>";
Could you possibly post some examples of what
System.out.println("url: " + url);
returns?
System.out.println("url: " + url);
returns?
ASKER
Here are the sysout msgs:
uri: file:////Comp1/Public/Test %20Scan%20 Sent%20Ima ge/2008/06 /file-1.PD F
url: file:////Comp1/Public/Test %20Scan%20 Sent%20Ima ge/2008/06 /file-1.PD F
uri: file:////Comp1/Public/Test
url: file:////Comp1/Public/Test
So you're saying that those don't work as links?
ASKER
Yes.
When I try to manually open the file from the browser, I notice that the URI has 5/'s after "file:", but the URI or URL returned by the program has only 4 /'s. When I click on the program generated url/uri, nothing happens.
When I try to manually open the file from the browser, I notice that the URI has 5/'s after "file:", but the URI or URL returned by the program has only 4 /'s. When I click on the program generated url/uri, nothing happens.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to both CEHJ and objects for your time.
:-)
Try using File.toURL and use the URL