I have uploaded a file to application server's shared folder and the path for the same is some thing like "opt/webapps/myFile.txt".
I want to view/open this file from my JSP page browser, Please help me how to do it??
That should be done in Java code and not a JSP. A Servlet would read the file and stream it to the user. Note that the servlet shouldn't accept the whole path of the file as that would be a security risk.
My thoughts!!!
You can try using the java.util.Scanner to access the txt/* ,and get the result into java.util.List and redirect to JSP and display the result using JSTL tags.
Alternately,
You can place this code in some .java file and call it by a servlet and display in jsp
I am able to access and open the file which is of any type but the code is working only for local files. i.e., If I create a folder in my local machine and put some file there and can able open the same file.
Howerver, I am unable to open the file which stored in Appserver's NAS link.. I am giving the file path as /opt/...../x.txt, still unable to open the file I am getting 404 error.