Results 1 to 3 of 3
- 10-03-2009, 06:14 AM #1
Member
- Join Date
- Jun 2009
- Posts
- 7
- Rep Power
- 0
Folder Creation On Shared Hosting Account
Dear All,
I am a newbie to Java Web Application development. I had created a small web-app in Java which allows a web-app client to create a folder with name of his/her choice on the server. This works fine locally on Tomcat but when deployed the same on our shared hosting account with godaddy I got exception as Access Denied
Caught Exception: java.security.AccessControlException: access denied (java.io.FilePermission /var/chroot/home/content/b/r/i/bringlifeto/html/MyDemoDirApp/demodir/testdir write)
For your reference here is the code snippets
index.jsp
# <html>
# <head><title>Custom Directory Creation On Server</title></head>
# <body>
# <center>
# <h1>Customized Directory Creation On Server</h1>
# <form method="post" action="/MyDemoDirApp/UserDirDemo">
# <table>
# <tr>
# <td>Enter Name For Your Directory</td>
# <td> </td>
# <td><input type="text" name="dirName" /></td>
# </tr>
# <tr>
# <td><input type="submit" value="Create Directory"/></td>
# <td> </td>
# <td><input type="reset" value="Reset"/></td>
# </tr>
#
# </table>
# </form>
# </center>
# </body>
# </html>
UserDemoDir.java
# import java.io.*;
# import javax.servlet.http.*;
# import javax.servlet.*;
#
# public class UserDirDemo
# extends HttpServlet
# {
# public void doPost(HttpServletRequest request, HttpServletResponse response)
# throws ServletException,IOException
# {
# response.setContentType("text/html");
# PrintWriter out=response.getWriter();
#
# String param=request.getParameter("dirName");
# //System.out.println("Param Value="+param);
#
# out.println("<html><head><title>Directory Creation On Server</title></head>");
# out.println("<body><center>");
# out.println("<h1>Directory Creation On Server</h1>");
#
# ServletContext servletContext=getServletContext();
# out.println("<br><h3>servletContext: "+servletContext+"</h3>");
#
# String realPath=servletContext.getRealPath("/");
# out.println("<br><h3>realPath: "+realPath+"</h3>");
#
# try
# {
# //File f=new File(realPath+"/images/testdir");
# File f=new File(realPath+"/"+param+"/testdir");
# f.mkdirs();
# out.println("<br><h3>Absolute Path="+f.getPath()+"</h3>");
# }
# catch(Exception e)
# {
# out.println("<br><br><strong><i>Caught Exception:\n\t"+e+"</i></strong>");
# out.close();
# }
# out.close();
#
# }
# }
Here I had used java.io package which is not correct as it is used for IO on the OS.
Please Help
Regards,
Arpit U. Gadle
- 10-03-2009, 01:51 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Use code tags not bold tags when posting code.
The directories you are trying to access either don't exist on the server or your program doesn't have access to them.
- 10-03-2009, 02:04 PM #3
Member
- Join Date
- Jun 2009
- Posts
- 7
- Rep Power
- 0
Re: Folder Creation on server
Dear r035198x,
Thanks for your reply. Here is the o/p and you can check that i am trying to create a folder inside my web-app home directory
Output
Directory Creation On Server
servletContext: org.apache.catalina.core.ApplicationContextFacade@ 1801285
realPath: /var/chroot/home/content/b/r/i/bringlifeto/html/MyDemoDirApp/
Caught Exception: java.security.AccessControlException: access denied (java.io.FilePermission /var/chroot/home/content/b/r/i/bringlifeto/html/MyDemoDirApp/demodir/testdir write)
and got the exception
Pls put some light on this issue
Thanks,
Similar Threads
-
Checking the process's status in shared hosting
By vivek1982 in forum Advanced JavaReplies: 0Last Post: 01-29-2009, 06:39 AM -
Account mix problem
By nihongbin in forum Threads and SynchronizationReplies: 3Last Post: 12-10-2008, 05:05 AM -
Access Linux shared folder from Windows OS
By nitinpjairaj in forum NetworkingReplies: 3Last Post: 08-26-2008, 06:14 PM -
how to access shared file/folder in LAN
By ksheetiz in forum NetworkingReplies: 1Last Post: 05-24-2008, 04:54 AM -
creation of new folder in the mail
By an8086 in forum Advanced JavaReplies: 1Last Post: 07-15-2007, 05:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks