I want to upload multiple files using java: are there any articles on the subject?
Here's an excellent Java applet for uploading multiple files, including full source:
http://sourceforge.net/projects/jupload/
Your question is not clear. If you mean using Javascript then you can use libraries like extjs that provide control for multiple uploads
if you use java for web you can use jsp :
http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
Apache MINA has a ftp server written in Java - http://mina.apache.org/ftpserver/ - could easily be used with any ftp client to upload multiple files.
Related
I am trying to use latest jade pre-processor with apache, is it possible to use node server to render the jade files to html inside Java application and then host the Java application in apache??
(Jade is now Pug.)
You can use pug-cli to pre-process pug files into HTML.
https://github.com/pugjs/pug-cli
How can I upload and download images with spark as our web layer?
I found this example but it heavily relies on Jetty being the container and does not work for Tomcat.
Would love to see a full example.
Why not just use a standard servlet with built in functionality?
Sample Spark Servlet Here
Sample Java Code Here
I would just like to ask if there is a way to upload files in GWT WITHOUT using the Google App Engine and Apache Commons archives? I've been searching for ways to upload files in GWT but all of the solutions I find all make use of these two. I would just like to know if there is a way, because our app won't work if we use GAE and Apache Commons... Thank you very much!
Yes, the simplest would be (assuming you are saving files to Blobstore):
On GWT side use FileUpload. Here is an example on how to use it.
On GAE side use BlobStore upload handler.
The other option would be to use gwt-upload with GAE upload handler.
GWT does not have such feature. You need to use some existing library or handle multipart form submits by yourself (FileUpload class). There is for example a gwtupload library which I have used and it worked pretty fine (but it is based on commons-upload AFAIR). There are other libs for sure.
http://code.google.com/p/gwtupload/
Is there any way to implement write/read file with gwt on client-side?
I tried with java.io.File, java.io.Writer ... I couldn't succeed.
thx in advance!
Update: Please see my own answer for a solution
No, you can't write to files on the client-side. GWT only binds a subset of the Java language. Any file IO would need to happen on the server side through RPCs or some kind of web service.
It's possible with HTML5 in some modern browsers. Try lib-gwt-file. This library can read files from client computer and even supports DND. To see it in action follow this link.
More information on HTML5 FileAPI you can find in the specification.
To download a file from browser memory to the client computer you can use Data URI. Example is here. But this feature is supported by Google Chrome only. Also take a look at the following helpful function. It runs download without reloading current page:
public static native void setWindowHref(String url)/*-{
$wnd.location.href = url;
}-*/;
Another semi-crossbrowser way is Downloadify. It's based on flash. Check this example.
Recently, I've stumbled upon a library called client-io.
A simple library that brings the Flash File API to regular web apps
through GWT. ClientIO will help you offload some of the file
generation functionalities to the client, saving resources and heavy
computation to the server. Working Demo - http://ahome-it.github.io/ahome-client-io/
In GWT the classes in the client folder are only compiled into javascript hence it is not possible to use
java.io
since GWT does not provide compilation of the package
java.io
Hence you have to write text file through RPC only.
I am working on a project which is basically a Java application with an embedded IE browser (using JDIC 0.9.5) to display custom HTML files (stored locally that I created). I have a test HTML file with a JavaScript function that checks a simple form with checkboxes and alerts the user with a dialog stating which checkboxes are checked.
My question is, is there a way for my Java application to do the same procedure on the embedded HTML form instead of using JavaScript. I want to keep my application and HTML files simple without the clutter of JavaScript in my HTMLs or a pile of .js files.
Thanks for any help and guidance!
You have two options. Either shift the project to run the Java on the server side using JSP technology inside a web container like Apache Tomcat or Jetty, or write you web page to open up a Java applet.
The applet route allows you to run the code on someone else's machine, and as a trade off you will have to run the application in a strongly security constrained environment. After all, if someone were to run code on your machine, you wouldn't want it able to access your disk, etc.
The JSP solution will have you running the code on the same machine as your web server, since you (probably) control your own web server, the code will not be ran with as many security constraints enabled. This means the code can make requests to other machines, write and read files, etc.
You could replace your model with a client-server model using Java Server Pages (JSP).
If you are displaying the page through an embedded browser it is very unlikely that you will be able to get access to the DOM via Java.
One option is to use GWT javascript compiler to code in java and then convert to javascript. If it will only use IE, then you will only need to keep one of the generated .js files, so the clutter will be low.
Since you're embedding your HTML files in your own Java program, I would recommend you to use one of these 2 approaches:
1.- Use Javascript and structure the files cleanly, is not that complex.
2.- When you do the POST check the values in your Java code and return a new dynamically generated HTML file with needed info
I sincerely recommend you to follow the first option. Other options to work with Java in HTML would be JSP or GWT, but both will require a proper J2EE server, which would be overkill in your application