I am working on a part of my company’s project management system that is accessed via our Intranet. Currently there is a page that shows details about specific projects. On this page there is a field that displays the location of documentation that is stored on a shared network drive.
One of my tasks is to make this field a link that a user can click on to view / download the documentation. The file paths can sometimes get very long and confusing. So I want to give the user inputting the path a way to browse to the doc and retrieve the path for the link that way.
My thought was to put the following in my jsp.
I don’t really want to upload the file, I just need the full path as a string. The problem is that it returns the file path with the drive letter I have mapped on my local machine.
G:\Systems Development\Projects\… ProjectDoc.doc
Not everyone will have the drives mapped to the same letters. Also this could be one of several shared drives, with no real standard location. Therefore I really need to have the full drive path for the link.
\\DriveName\shared\ Systems Development\Projects\… ProjectDoc.doc
I can’t just trim off the drive letter and replace it with the drive name, because I won’t know what drive the doc will be on, and like I said not everyone will have the same drive letters mapped.
Anyone have any solutions, or at least a direction to head?
Matt Mac wrote:One of my tasks is to make this field a link that a user can click on to view / download the documentation. The file paths can sometimes get very long and confusing. So I want to give the user inputting the path a way to browse to the doc and retrieve the path for the link that way.
I don't understand this. You want to put a link in the page to a document. Okay, the link is long and tedious but you only have to do that once, when you create the page. But then you're asking about a user "inputting the path". What user is this? Doesn't the link in the page already point to the document? Is this user the one creating the page in the first place?
The link will not be static. It will be pulled from a database along with other information about any given project within our company and displayed using EL within a jsp. This information can be edited at any time during the life of the projects.
I will be building the link to display based on whatever file path is entered on the “edit.jsp”. Then anyone involved with the project can look at the “display.jsp” to see where the doc for that particular project is located. I would prefer that the person entering the data not have to manually type in the file path.
The documents are not on the server. They are stored on shared drives that are accessed from the client side.
The user needs to establish a network shortcut for the share. To do that, In Explorer, right-click on Network and select Map Network Drive. On the resulting dialog box, ignore the two input fields and instead look at the link underneath them. On XP the link is buried within a paragraph below the input fields. On Windows 7 the link is named "Connect to a web site that you can use to store documents and pictures", I imagine the link is named similarly on Vista (right now I only have access to a Win7 system, I can verify the XP and Vista links later if needed). Click that link. In the resulting dialog box, choose the option to establish a connection of the network. On Win7 it is labeled "Specify the address of a website, network location or FTP site" and click Next. In the "Internet or Network Address" text field enter the UNC location for the share (e.g. \\hostname\share) and click Next. The default name is "share on hostname", you can keep or change that. Click Next and then Finish. The new network location will appear under the Network in Explorer (on XP and perhaps on Vista, in Win7 it appears under Computer).
The prep work is not done. To test it, in Explorer expand "share on hostname" and browse to a file. Then look at the filename in the address bar - it should be the UNC name - \\hostname\share\path\to\the\file.doc
Back to the web app. When the user now clicks on the browse button for the file field, the user can use the "share on hostname" network location to browse to the file. The file field should forward the UNC filename to the web app. You might want to have the web app verify the the user did remember to use the UNC filename (check the formatting). In addition, provided that the web app is running under a security credential that has access to the share, the web app could attempt to access the the file (File.exists() is sufficient).
By the way, establishing the network location is not absolutely necessary - the user can always browse, via Network, to the network location. But if your work's network is anything like mine, there are thousands of hosts and shares to dig through. Specifying network locations for shares of interest makes accessing the shares you are looking for much easier.
Matt Mac wrote:However, I want the person inputting the file path to have the ability to browse to the file to retrieve the file path. I don't want to rely on them typing the path in correctly.
You've misunderstood; I was suggesting a system where the user uploads the file and the system has a localized copy it can serve back.
Some browsers don't even submit the entire pathname, just the name of the file--they might have to enter the path anyway.
You can do something like this.
See, your documents must be lying on an actual path on the server, for example C:\documents\ujjwal.pdf
Now, you are displaying links to the user, now on the click of that link, you want the document to be displayed or downloaded to the client machine. You can do something like this: