I have got a folder with many excel documents in it on tomcat and i want those files to be available when i got go the that folder's url in the browser (eg http;//localhost:8080/myfolder)
at the moment when i try to access a folder i get a 404 error. by if i try to access a file that is in that folder, it works.
In order to access your system files from browser using tomcat,you have to create context path for the system files in tomcat server. xml like below. Now you can see the files in your browser.By typing the below url.
By default, these files are located at TOMCAT-HOME/conf/server. xml and TOMCAT-HOME/conf/web.
list() returns the array of files and directories in the directory defined by this abstract path name. The method returns null, if the abstract pathname does not denote a directory.
By the sounds of it, your application is storing files in the current directory of the JVM, which happens to be the "bin" directory when you launch the web server via NetBeans. If so, you will find them, in whatever the current directory is when Tomcat is launched as a windows service.
The DefaultServlet
of Tomcat is by default configured to not show directory listings. You need to open Tomcat's own /conf/web.xml
file (look in Tomcat installation folder), search the <servlet>
entry of the DefaultServlet
and then change its listings
initialization parameter from
<init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param>
to
<init-param> <param-name>listings</param-name> <param-value>true</param-value> </init-param>
Keep in mind that this affects all folders of your webapp. If you want to enable this for only an individual folder, you've got to write some Servlet
code yourself which does the job with help of the java.io.File
API in servlet side to collect the files and some bunch of HTML/CSS in JSP side to present it in a neat fashion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With