File download / upload through browser to specific destination folder - java

I'm working on a web application which needs to download/upload a file from/to the server. The user base for this application, however, is not tech savvy so we we want them to click a button that indicates "Download file" (for this record) or "Upload file" (for this record) without having to rely on the user to "Save As" or indicate the destination folder. In a previous version we've used Software Artisan's SAXFile (an ActiveX control) however we're trying to avoid ActiveX this time around. We're hoping to make the application browser agnostic.
Any suggestions about how to do this? I'm assuming we'll have to do a java applet, but if there's an existing open source project or control I'd rather not roll my own.

This is a security issue, that's why there's not many good options out there. The ability to write to an arbitrary directory is definitely not something that should be granted to any web page.
Your options are a Java Applet, Flash, HTML5, or ActiveX, but all of those require the user to grant permissions, or select a location. You could also accomplish this with HTML5 Web storage, which doesn't require user permissions, but is more limited, both in storage format, browser support, and size limits (5 or 10 MB for most browsers)

Related

Embedding Microsoft Word in a browser window (cross-browser)

Background
Our web application stores Microsoft Word documents which users want to edit (ideally with Word) in their browser of choice.
To access the web application (and the documents), users must login. As they are unwilling to login whenever they edit a document, document retrieval and storage must occur in their login session, which is easiest to accomplish if document download and upload is done by the browser.
Question
How can I embed Word into (or at least invoke it from) a browser window to edit a document the browser has retrieved from the server? It should work in both Internet Explorer and Firefox.
Own Research
ActiveX is not supported by Firefox.
There is not javascript api for invoking (let alone embed) native applications. Even if there were, I don't see how I could pass the document, and neither Internet Explorer 10 not Firefox 20 appears to offer an api to write a file to disk.
I could write a (signed) Java Applet to invoke Word, but ensuring that all changes are uploaded to the server appears difficult (what if the user closes the browser window before saving in Word?)
Eclipse has this nice feature of permitting in place editing word documents. This appears to be part of their SWT toolkit, but as that requires native code, I am not sure how to deploy it is an applet?
I don't know if they are embeddable for free, but you can take a look at Microsoft Office Webapps

JSP Limit the directories of a File Open dialog

I am currently coding a program using the language JSP. I was wondering if/how you would restrict the directories a File Open dialogue box can browse, for instance:
The default directory is in C:/userFiles/username/ I want the user to be able to browse files in that /username/ directory, or directories within that directory, but not any directories above like C:/, or C:/userFiles. I have done some research, and I could not come across an answer. Is this possible with JSP, HTML, or Java and if so, how would I do it? I would prefer JSP or HTML.
Additional Info:
The dialogue box would browse files on a remote server, not on the user's computer.
The File Open dialog is on the client machine and is part of the operating system. You cannot change its behaviour.
In order to list files on a SERVER you would not use a File Open dialog, you'd be turning the list of files into HTML and serving that to the browser. Since you're the one writing the server-side code, you are ALREADY the one in control over which files make it into that list in the first place.
Saying you'd prefer "JSP or HTML" is a pretty good indicator that you don't fully understand the client-server relationship of the web.

Ways to open a folder/explorer client side from a web page.... Java applet?

I have a need to "pop up" operating system folders from my web app, mostly to locate files in them. My users don’t want to use a conventional web upload/download paradigm. I have 7 or 8 static folders that need to be opened in explorer on a PC or in Finder on a mac. These folders are all network available, but are buried, and for convenience need to be shown on a web page.
There are IE tricks to do this, and I've written a sample flash app that only allows the browser to open, but I know most browsers sandbox this, and keep me from calling these folders. I am aware that some Java libraries deal with the opening of folders, does anyone have any thoughts or samples for this?
The only way I can imagine is to create a Signed Java Applet.
Applets cannot access the filesystem (and a lot of other ressources) if they are not valid signed. Maybe you can also grant the permission by a policyfile.
There ist a tutorial at JavaRanch.
But I am not sure, if this solution will be very helpful, because the JavaPlugin will be removed from a lott of browsers in near future. (I think FireFox already removed it).
I think there is actually NO solution to this problem.
There may be some workarrounds:
Put a Batch-File onto the server, which opens the folder, if executed
Can you create a local service, which handles requests from you webpage and opens the folder.
Create a webapplication, which opens the folder at serverside, and create a webpage, which displays the content in you website.

Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction?

I am looking for a way to save a couple of files created with JavaScript on the clients computer. I want him to be able to choose a folder (similar to open/save folder dialog), and then write the files there. This obviously requires three things:
Ability to popup such a dialog.
Ability to write on the client's computer (signed applets?)
Some way to interact with JavaScript because it knows the filenames and contents to write.
Is this possible or should I just stop dreaming?
It sure is possible.
One way is to use a signed applet, but if your users are willing to upgrade to Java 1.6.0_10+, a signed applet is not needed. Since 1.6.0_10 (the Next Generation Java Plug-In), JNLP API services are available to embedded applets. Here is a demo. of the JNLP file services.
I see the other reply has already covered the applet/JS interaction.
It is possible with a signed applet.
I'd probably do it the other way around, let the javascript code pass all the data to the applet and the applet should open a FileDialog and write the file.
Calling javascript from java can be achieved via `JSObject, calling Java from Javascript is explained here
If your applet is signed you can do everything that you can do in regular application. You can open "File dialog" but it will be the Java's dialog, not the same that is opened when user pushes "browse" button of tag <intput type"file"/>. Obviously signed applet can perform read and write operations with user's disk.
All applets (either signed or unsigned) may call javascript using JSObject. You just have to say MAYSCRIPT="true" into applet tag.
I think that you cannot open the browser's "file open" dialog applet. Actually you even cannot open it using regular javascript. (I'd be happy to know that I am wrong at this point but I spent some time trying to do this and failed).

Java Applet to manage file uploads to server

Looking for a descent looking Java File Upload Applet (or even Flash) that fits the following requirements:
Free/cheap (yes looking to use in a commercial web application)
Preferably allow multiple file selection
Ability to create/edit folders on destination server? (within a secure root folder)
Ability to overwrite files in the destination directory?
IE + Firefox support required... Safari, Chrome, etc. a bonus
Ability to "hook" into the flow to apply additional logic
Notes:
In particular I'm looking for the ability to upload to a directory on another server (e.g. not where my web server or app server is running)
The destination server has a shared drive where all users of the app have permission to store files.
By "decent looking" I'd really, really like to avoid a UI that is "skinned" like this:
(source: swtguibuilder.com)
Before I'm shut down for "not programming related" I would need to be able to hook into such an applet to apply some additional permission logic etc. I don't want to re-invent the wheel if someone else has made a component that already does what I need.
This is relatively easy with Java. Look into Apache Commons Fileupload for the server-side code. For the front-end, there are many examples of flash-based file uploads.
The simple answer to your question used to be Flash. Since the release of Flash Player 10 it isn't anymore. Adobe has added a restriction on File upload which only allows a file to be uploaded in the scope of UIA - User Initiated Action. This means that a file upload must be started with a mouse click.
There are some of free file uploaders built in flash available. The only problem is that the queuing is broken by FP10. Adding the files to the pending uploads list is no problem. Starting the upload is no problem either. But when one file upload is done and the next should begin, Flash Player will not allow it if you don't click again which is pretty much useless.
There at least two requirements:
Applet file uploader These are available, e.g.: http://sourceforge.net/projects/jupload/
Widget to configure destination This is unusual in my experience, but I wrote one once for a Swing app which would be similar for an applet. It was necessary to provide the user a view of the remote file system, enable manipulation of the view, and then upload the changes. Note that there are transactions issues here, so it's not trivial.

Categories

Resources