vaninf Posted June 14, 2017 Share Posted June 14, 2017 I have a JSP file mkdir.jsp in folder /home/vaninf/public_html/, it tries to create a directory and file, but I get "Permission denied" exception. How can I create a directory or file using JSP script? How can I get the permission to do it? Thanks. Quote Link to comment Share on other sites More sharing options...
Krydos Posted June 14, 2017 Share Posted June 14, 2017 The user that Tomcat runs as doesn't have permission to create directories for security because this is a shared host. Just create your folder manually, or create it with PHP. PHP is allowed to create directories because it runs as SuPHP which means it runs with the same permissions as your main user account. There is no such thing as SuJSP so Tomcat has to run all users with the same tomcat user with the same permissions. Quote Link to comment Share on other sites More sharing options...
vaninf Posted June 14, 2017 Author Share Posted June 14, 2017 My JSP web application will allow users to upload image files, so my JSP scripts has to be able to create directories and files. I searched internet and find this site: https://stackoverflow.com/questions/35428172/tomcat-permission-denied-when-trying-to-write-a-file Can you run these two commands:chown tomcat:tomcat /home/vaninf/public_htmlchmod u+wrx /home/vaninf/public_htmlso that my JSP scripts can create folders and files in my home folder. Thanks. Quote Link to comment Share on other sites More sharing options...
vaninf Posted June 15, 2017 Author Share Posted June 15, 2017 The problem is solved. Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.