Uploading image and updating

0

I have an application in javaEE where one of the requirements is to upload an image used for the user profile.

Everything you've been up to now:  1. Selects the image to be edited (Cut, Rotate and etc);  2. The photo is passed as base64 to the Servlet;  3. The image is converted into a png file and saved in a directory [media / pic / example-img-hash-name.png];  4. Saves the image name in the user database;  5. Return the image name and change the "src" attribute of the image with javascript;

So far so good, but the image does not update. I also try to access the image through the link and I can not. Only after restarting the server does the new image load.

Is this a server configuration? web.xml? I'm using IntelliJ IDEA + Tomcat

    
asked by anonymous 24.12.2016 / 01:51

1 answer

0

In the IMG TAG SRC attribute, enter a variable that we call the "no-cache" identifier. generate a random number that will change with each request. So the cache of both the browser and the servlet will not respond to the cache but the correct query.

EX:

I hope I have helped.

Hugs!

    
24.12.2016 / 02:59