I'm using tomcat 8 and uploading image to server by this code:
public static String uploadImage(String description, HttpServletRequest request) throws ServletException {
Part filePart;
try {
filePart = request.getPart(PARAM_NAME_IMAGE);
try(OutputStream out = new FileOutputStream(new File(PATH + description + ".jpg"));
InputStream fileContent = filePart.getInputStream()){
int read;
byte[] bytes = new byte[1024];
while ((read = fileContent.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
}
} catch (IOException e) {
LOG.error("IOException", e);
}
return PATH_TO_IMAGE + description + ".jpg";
}
Then i save image path to DB for my item. And then i want to see it on the page by using:
<img src="${item.imagePath}" width="350" height="320" />
And then if I restart server everything is ok and its shown
So, I need to see what I upload without restarting server