I have a web application running on Weblogic 12c using Java7 as backend and angularjs in front end.
I want to be able to download/upload one (pdf) file from it.
The basic user cases are :
The user can click on a button to download the file.
The user can click a button and pick a local file, this file will then be uploaded and replace the previous one as the downloable file.
There will only be one file.
I've tried to find a solution online and I ended up creating a File Store (with a direct-write policy).
But I haven't found how to download the file when using my application.
Also, I'm not sure this solution will work for my upload case.
How can I et up my application to download/upload this file ?
Filestores are a wholly different concept, used to store JMS messages. Don't let the name confuse you, this is not a usecase for filestores.
Consider this Q for handling the file upload: How to upload files to server using JSP/Servlet? - and save the file on a folder in the filesystem. Your WebLogic 12c installation supports servlet 3.0 annotations.
Related
I'm developing local-only JSP application using Apache Tomcat server. I would like to put a promotion videos on my intro page, but I don't want to move them to webapp folder or anywhere else.
The promotion videos are located:
E:\data\videos\2018...
But writing a JSP/HTML like this wont launch the video, but however it works off-server (launching html from desktop for example, so the path may not be issue?)
<video src="file:///E:/data/videos/2018/promotion1.mp4" controls></video>
Local file links from remote resources are disabled by almost all browsers by default. There are certain possibilities to overcome that, e.g.:
http://kb.mozillazine.org/Links_to_local_pages_do_not_work
https://discourse.mozilla.org/t/opening-links-to-local-files-file/16449/2
To access your static media files from remote page you need to configure your Tomcat server as described here: http://teknosrc.com/access-local-files-static-content-images-videos-media-files-outside-web-application-system-apache-tomcat-server/
solution:
a.) make sure your server is on the same system where the media files are.
b.) If so, you have to create a folder (ex. media) in your application folder inside /src/main/webapp/ and have to put all media files inside a media folder. After that, you can surely access the media files through a server.
So I have a java webapp that lets the user upload a file to a server. I am using apache commons library FtpClient to do that.
I want to be able to match the uploaded file with the user of my website (the web app is only accessible from within the user area on the website). The website and whole user-interaction and management is in PHP / MySQL. So basically, I want to match the file uploaded in the Java webapp with the user in MySQL table who uploaded it.
How should I use PHP on the server to grab that file and match it with the user? Or maybe it's more convenient to do that from Java application somehow? Which approach do you suggest?
You could call a JSP by post with the file name that has been uploaded and the user name or the user id, This can be used to update or insert into a database where you can save the relation between the file and the user.
Hope this solves the issue.
Currently i have a java applet (with tomcat 6 as backend) that allow users to upload file and download file for document sharing. However, many users forget to upload the edited file back to the server.
Hence, I would like to enhance the applet to allow user to choose a file* for edit and save directly to the web server. Without having the user to save the file to their local harddisk, and upload the file* back to server manually.
After a few goggling, it seems WebDav is the way. I have configure tomcat with the webdav enable in the web.xml, and now i can view file and edit with a Webdav client CyberDuck.
Questions:
is it possible view / edit / lock the file* without installing a webdav client?
Reason is because i have more than 3000 desktop client using the software. Deployment of the webdav is an issue and how do i let each user to access different webdav so they do not see each other's file?
Is it possible to trigger local application to open a file* inside WebDav?
file* = means any file that are able to open from their local machine; examples: ms word, ms excel, ms powerpoint, pdf, PNG, JPG, txt and etc.
Ah, i manage to open it with:
Runtime.getRuntime().exec("winword http://:/xyz/.../pgl_page-bi.doc");
Problem is, every single type of files will need to have a different string inside the .exec(""); not as clean as i expected but at least it works.
A web application uploads files (images only) from client to server location no any DB and also save the same file/files from server to client's machine.
Process 1. upload a file <input type="file /">
2. save files into server predifined location : java
3. download the same files from server to client's machine by clicking on save button
problem : let suppose there are two users and they are uploading different files with same name at same time in predifined (or programmed) server's folder.
then how should i avoid this kind of naming conflict & how to programmed for, which file belongs to whom (client) .
possible sol'n : during uploading the file from client to server, create one folder for each client and save the file into specifiec newly created folder.
please note that there is no any Database in application. please suggest any better
Environment : java servlet Apache-tomcat 6.0 xhtml
Use HttpServletReqeust.getSession() method to get client's unique session and then HttpSession.getId() to get session's identifier which you can use in directory/file name construction.
create one folder for each client/user.
Seems like the obvious solution to me. Using session id will result in many more directories being created. If the server saved images are to be used later(which I assume they are, otherwise whats the point of saving them). Having a directory structure based on usernames(or similar) would be much less painful to navigate than anything else.
I have a java web service through which I upload images to a file server. I want to access these images from my java web app. How can I make the image files (and eventually other static files) available from this file server?
The only thing I could think of was to use Apache Http server as a proxy to my web app for these images, but that circumvents the security measures of the web app.
UPDATE:
Servlet container: Tomcat
Web app is on separate server from images.
Web service is on same server as images and has direct access to file system.
Both web app and service use spring security for authentication/authorization, I want to continue to use this security framework to for image access.
How are the files stored?
If security is a concern the best option might be to create a Servlet (or something similar) which will load up the image and serve it to the user, once it has checked their credentials.
How you load the image depends on exactly how they're stored, if you can access them via HTTP you can always open up a URLConnection to the file from the Servlet and serve it directly that way (i.e. using the Servlet as a sort of proxy server).
Without more details it's difficult to be specific.
I'm not sure if this will solve your problem, but it sounds like you should set up a context path that will map a URL to the path on your server. This can be done with tomcat's context files.
For a good explanation of the solution, check out a post on How to Program with Java
Sounds similar to Apache Hadoop.
Once image/file is requested, you have to make API call and pull the file out and do one of the following:
Store the temp file to the "temp" directory on web accessible server. You will need, some kind of cleaner/gc running in the background to clean those temp files. This is how Facebook does it with photos.
Instead of storing file on the server check the file type and set HTTP Content-type header to the appropriate file type. Image source will look like this <img src="getPicture.jsp?id=1234" />