I am fairly new to web development. I am using Eclipse 3.3.2. Our Intranet uses the Struts framework and Apache Tomcat 5.5 server. Most of us are using Firefox 2 or 3, but not necessarily everyone.
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.
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?
That’s what I was afraid of. I don’t mind doing the research, but could someone possibly point me in the right direction. Or, even several directions to explore. I am inexperienced enough that I am not aware of all of the possibilities out there.
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?
Joined: May 20, 2009
I’m sorry. I’m not explaining this very well. I am new to using forums as well.
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.
How else would the system know where the file is unless the user enters the file path in a way that's meaningful to everybody, and not dependent on people mapping known locations to custom drive letters? Unless the file is uploaded to the system and put in a location known to the application I don't really see how to do this.
Joined: May 20, 2009
That's the point. 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.
From what I understand you want the user to be able to browse to a network share and have the UNC filename used as the name of that file. It can be done but the user needs to do some prep work first.
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.
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:
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Joined: May 20, 2009
Well, thanks everyone for the responses. You've all pretty much told me what I was afraid of. What I want to do just won't be possible the way that I wanted to do it. I think I'll have come back to my boss with a proposal for a document upload repository so that everything is standardized.