Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching for files on separate server using partial file name -- servlet or javascript ?  RSS feed

 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have PDF files that contain customer documents stored on a public drive on an AS400. I need to set up a page for users so they can search the documents using a tracking number that is part of the file name. The users running the search may be using a thin connected to a terminal server or they may be using a desktop. We are not using any kind of active directory or domain management at this site so the servers are addressed by their full IP address. All three servers (tomcat, terminal, as400) are on the same LAN.

I have looked on coderanch.com and it seems that if the servlet is on one server and the files are somewhere else the servlet cannot use the folder.listFiles() to look at the target server. But this is a big site and I might have missed some thread that has addressed this topic. Is there a way to search a remote directory with servlets or is my best option to make an html page in the directory with the documents and have javascript do the search?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript has no ability to search for files on the server. So, that's not an option.

Is there any sort of server running on the remote system that can respond with a list of what you need as a web service, perhaps?

Obviously security concerns prevent just anyone from poking around the file system of a remote machine.
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there any sort of server running on the remote system that can respond with a list of what you need as a web service, perhaps?


Apache I think, but nothing I would be allowed to work with. It is the accounting system and highly restricted.

Obviously security concerns prevent just anyone from poking around the file system of a remote machine.


The directory with the documents can be seen and uploading is password protected. There are a couple parent directories that are listed but they go to a demo software package that has expired. The scanners log on to the server. Users get to the files by opening the directory in a browser with the document name as part of the URL.

When the people scanning documents name them the naming conventions not always followed, especially if there are multiple documents for the same PO. If I am a user and I know there are several documents for a po but I don't know what they are named I either guess at the name or go to the URL without a file name [url removed] and get the entire directory of 13,000+ files as list. So a file named "C4016, Z0940, Z0941.pdf" is going to be hard to find. A User looking for Z0940 is in a worse spot. In the directory anyone can see all files if they are on the local network. All I have to do is put the directory path in my browser and I can see it.

When the directory is opened without the file name it dumps the files as a bulleted list . There is no web page source for this list.

Is the response to the directory name without a file name something a servlet could capture ?
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a Javascript thread here http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/144152/how-to-list-all-files-in-a-folder-including-subfolder-files that talks about

A more web approach to this would be to use the XMLHTTPRequest object to fetch a directory (instead of a file) from a web server. This will bring back an HTML page which list the files in the directory. You can then parse through the html and find the directories. With apache you can recongnize a directory because there will be a link with the href value equal to the text node in the link.


Is the XMLHTTPRequest available to servlets, too ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
margaret gillon wrote:Is the XMLHTTPRequest available to servlets, too ?

No it's a JavaScript thing -- you might have heard of it as Ajax.

That all assumes that there's something on the server that will return the list of files in the folder give a URL via HTTP. If that's already in place (which I assume it is by your previous post), the there are a number of approaches you can use, wither on the server or the client.
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know about Ajax but have not written with it.

If that's already in place (which I assume it is by your previous post), the there are a number of approaches you can use, wither on the server or the client.


How do I find out for sure? Then what are my options? If it helps and if there are examples I could modify -- I have your Javascript Ninja book and your Jquery book.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That way to check is to see if there is a URL you can type into the browser that will return the list of files. If the browser can see it, then so can Ajax (some limitations here), and so can a servlet using an HTTP connection.

The hard part may be parsing the response containing the info if it's not in an easily consumable format. If for example, the list is like you showed earlier -- which looks like a display returned by Tomcat or Apache -- then there's some "screen scraping" to be done. If you're more familiar with Java than JavaScript, it might be easier for you to handle this on the server.

The most important thing to find out at this point, is what you can get from that server. If there's an existing web service that returns JSON or XML, that will be a lot easier to deal with than a format intended for display (raw text or HTML).

(P.S. Thanks for buying my books!)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!