Store file on Tomcat Server or any other servlet container

Option 1: Get application Real path

filePath = getServletContext().getRealPath("") + "/docs/" + filename;

Option 2: Save the path in WEB.xml

filePath = getServletContext().getInitParameter("filePath") + "/docs/" + filename;

Create directory if one doesn't exists

File file = new File(filePath);
        if (!file.exists()) {

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.