Creating a folder within web server under /public_html/ in Java

天大地大妈咪最大 提交于 2019-12-06 02:29:42

To point to public web directory use

ServletContext context = request.getServletContext();
String path = context.getRealPath("/");

and append your path to the path (above resolved)

According to my understanding, when I target "xyz.com" , it by default points out /home/xyz/public_html/ in my server.

What makes you think so? You're operating files in the code snippet given, so your path means /xyz.com/appFolder/ and nothing more. And it's very likely you're facing a permission issue trying to create folders like this.

As for absense of exception, that's a design feature of Java file API not to throw exceptions on certain failures, but rather return erroneous error codes. Check what is returned by mkdir() call and you'll find false there, as a signal of failure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!