So, I followed this tutorial to upload files to a servlet:
http://www.codejava.net/java-ee/servlet/java-file-upload-example-with-servlet-30-api
It creates a folder (if it doesn't exist) and uploads a file to that folder.
Once the upload in complete it displays a page saying that the upload was successful. I've seen other tutorials, such as this one:
http://www.javacodegeeks.com/2013/08/servlet-upload-file-and-download-file-example.html
That display a download link, but only for the file that was just uploaded.
I want to create a page that uploaded a file, then displays links to download all files that have been uploaded (or a button to direct one to such a page).
Suppose you're uploading all files to X folder
Then, Simply iterate over X folder to get all files
for(File f:new File("X").listFiles()){
//Iterate here to create download links for each file
}
You may use http://www.javacodegeeks.com/2013/08/servlet-upload-file-and-download-file-example.html for each of the file to create a download link
Related
I have one zip file (C:\source.zip ~130 mb size) common source in my server, I want to create new text file that depends on user info dynamically and append into that source.zip, then I need to give a download link to separate user.
My idea is, I will combine the source.zip and new user text file into one temporary folder (c:\temp). Then I will give the temporary folder as download link. After user downloaded the zip, I will delete the zip file in temp folder.
But my problem is, I will duplicate source into temp folder. So many users access this means server size will increase. So I want to read the (source.zip and text file) zip archives with no intermediate disk/memory storage to download in servlet.
How can I do this in servlet or jsp?
I want to create a hidden folder in user's Google drive root directory and then want to insert some text files in that folder and later want to retrieve that files. I tried the quick guide and files are uploading fine but in the root directory and files are visible to user. From here I know how to create an empty folder. . But from here I do not understand how to use that code to insert the file in a particular folder.
So my Question is how to create hidden folder and perform CURD operations on files using drive API.
You're looking for the appdata folder. See here:
https://developers.google.com/drive/appdata
I'm doing a web application where I can upload and download pdf files from server.
In this I created a pdf files and stored its path on the database.
What I want is when I search by some criteria (like filename) I should get list of files from db. When I click open link it should be opened in jsp.
Downloading part was done by me. What I need is just to open a pdf in jsp.
is it possible to open server file from jsp?
Place those files outside WEB-INF folder and access. WEB-INF folder is secure in a Java EE environment. By placing your files inside the WebContent folder and outside the WEB-INF folder will help you to access those files for download. You need to mention the full path for that file. E.g for an image your path will be https://localhost:9444/AppName/resources/theme/images/logo.png
i want to download folder containing files like pdf,jpg,png etc from web services.I have written a application that can download pdf,png file.But i want to download folder containing several files. So my question is- is it possible to download folder and if yes then how can i download folder from server in android. thank you
If you can download one file, why wouldn't you be able to download several? Create the folder on Android, queue the files and start the next download when the current is finished, filling the folder. Also Android supports ZIP, so that might be your best call.
Folder is nothing but an FILE but a different type of file. Once you get the folder you can list down the files in it. You already have URL with the folder, u just need to append the URL of the folder to the files in it and download them one by one.
hi i am uploading my images using the
String filePath = context.getRealPath("/")+"/Library/";
all of the images are get to saved in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
when i list the files in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
from terminal i can see the images that were uploaded. but if i list the files in
.../workspace/MyProj/Library/
i cannot see them. also from eclipse (inside project explorer)
MyProj
->Library
i cannot see the images uploaded. then i thought probably that location is kind of temp location, and restarted my computer. but uploaded images are still in
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
but through eclipse they are not visible, doing file->refresh also did not help. my questions are follows will the uploaded images stay in this location
.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyProj/Library/
and why i cannot see them from eclipse? if it is possible can you show me how to save them directly in
.../workspace/MyProj/Library/
thanks!
You can't see the images because eclipse has deployed your webapp to a server and your images are being uploaded to the server.
You can save them directly to your workspace by using:
System.getEnv("user.home")+"/workspace/MyProj/Library/"
instead of:
context.getRealPath("/")+"/Library/";