-1
I have a javaEE application where I use Tomcat 8. In it, I mapped an external folder to save the images that the user can register on one of my application screens. To do this, I went to the server.xml file of my Tomcat and did the mapping. Everything was working well for a long time, only yesterday, I ended up deleting Tomcat 8 and had to add it again. As a result, I had to redo the mapping configuration in the server.xml file.
When redoing the configuration, simply mapping does not work anymore. I already gave a clear in Tomcat, I already gave a clear and update project in Maven, and nothing. The context of my application is '/Picos' and I can access it through
localhost:8080/Picos
From there, in an attempt to redo the configuration, I went to the Tomcat.xml server and added<Context docBase="C:\Picos\images" path="/images" />
within the tag <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
, and simply when I put the address in the browser localhost:8080/Picos/images/1.png
(remembering that 1.png image exists inside C: Picos images folder) I get 404 error.
What I’m doing wrong, since before the crash of deleting the Tomcat server in eclipise, everything was working perfectly. Am I missing any other settings? Any tips? Thank you
It is not recommended to change the
server.xml
. This configuration may even work to perform tests locally, but in another context it should not be applied. Also, change thedocBase
of the entire application can cause devastating side effects, since not only the images, but all the application’s Resources will be accessed from that directory. In security matters, s and a user send a JSP instead of an image, it will be able to execute any code on the server.– utluiz
So how would it be the right way?
– sThiago
It depends on how your application works, but the simplest way is to install the application normally and create a Servlet to serve the images.
– utluiz
Note that this would be different if the images were not registered by an external user.
– utluiz
Uploading images are done by users, through an Android app
– sThiago