I am performing a task in Java Struts2 Framework. Task is uploading a file and view the file when click on a specific link.
Problem is I am able to upload the file in desired folder. But when click on link It is giving 404 error, although file is uploaded in correct location as in link.
If I refresh project, then I am able to see the file on same link.
Without refreshing project, Can we see the file in browser in STRUTS2 framework?
Thanks
If you are running a server in eclipse then it may be resolved when you deploy it on the Apache Tomcat Server because when you run on internally all data stored in the cache memory which is temporary while the server is running once you stop the server you will lose your data.
You just create the method to open the uploaded file, and use () tag to instead of anchor tag for Link and call the action mapped with file opening method. In method you just write the code to open the file on client computer.
Related
I've been asked this time to also create a test script for file upload in a JSF application using JMeter. The generated script from blazemeter is as follows:
generated script for input form
The encircled value is the file name. I have noticed that the parameter was not created under "Files Upload" tab, so I have also tried to move the parameter to File Upload tab, using the generated content type in our application logs when uploading as Mime Type in JMeter:
Jmeter file upload tab
Generated content type
But it has the same result when I first tried the script where the file name parameter was still under "Parameters" tab (file name is null according to localhost application logs):
Application log indicating that file name is null
The UI of the file upload is this. The user clicks browse button, picks a file then the name of the file is displayed in the input field (Import File). The user would then click the Import button to submit the form:
File upload UI
Am I missing a step or doing something incorrectly?
Thank you in advance! Any help would be greatly appreciated.
Your way of building a file upload request might be wrong, if you want to continue manual experiments I would recommend comparing requests which are being sent by JMeter and the real browser using a sniffer tool like Wireshark. Apart from ${VIEWSTATE} the requests should be exactly the same.
An easier option would be just re-recording the request (you can record only one single request) using HTTP(S) Test Script Recorder.
Prepare JMeter for recording. The easiest way of doing this is using JMeter Templates feature
from JMeter main menu choose File -> Templates -> Recording and click "Create"
expand HTTP(S) Test Script Recorder and click "Start"
Prepare your browser for recording, refer your browser documentation in order to set up proxy using localhost as the proxy host and 8888 as the proxy port, the proxy needs to be set for all protocols with no exclusions. The relevant configuration for Mozilla Firefox (the only free and open source popular browser, moreover it has separate proxy configuration which does not derive from the operating system) would be:
Copy the file you will be recording to the "bin" folder of your JMeter installation. If you omit this step JMeter will not be able to properly record the request. See Recording File Uploads with JMeter article for more details if needed
Execute the request in browser - the relevant HTTP Request sampler will be generated under the Recording Controller
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.
I develop a web application using JDeveloper. Then, my scenario is I want to get a file from client directory (e.g. C://Image.jpg). What I want to achieve is the client's directory defined programmatically. So, I used InputStream, but it will search a file in server directory. if I used UploadedFile, I don't know how to define it. Note that I don't want to use InputFile.
Does anyone have a solution for me?
Search for HTTP File Upload. You need an <input type='file'> control on your webpage, and form encoding set as enctype='multipart/form-data'.
Generally, you can't control the default directory where the browser is going to open a file chooser -- it normally starts from the "user home" directory, but other dirs can be navigated to.
suppose in my web app user click on download button so a file downloaded into his system. So can i get that client's download location like where the recent downloaded file present in my client system
You cannot get this information.
It is sandboxed, the server will not be informed by the client about the location.
This is not possible since you don't have access to user's file system through the browser (JavaScript).
Maybe using a module or whatever directly in the browser.
You don't. All you get is the file name...
What woule it help you anyway as your server does not have the same structure.
I am trying to develop a J2EE web application which reads files from the local machine. The user will be able to enter a path where the file exists and when a button is clicked, the file is read and a database should be uploaded. This feature works fine when I tested it locally, but when I moved the code to the web server, it is not able to find the file. This is because the application is trying to find the file at the server and not the local machine. Could some one please let me know if there is any way I could read the file from the local machine?
I ve been using struts/tomcat for developing this application
Thanks
An option: Check out this Rose India article
Another option: do a google search for "file upload jsp"
try
<input type="file"/>
It is impossible to read a file on a remote computer without sending it to the server... obviously!
Local file access is usually permitted if you run the browser App from the local file system, and not thru an Web server.