Results 1 to 3 of 3
  1. #1
    arpitgadle is offline Member
    Join Date
    Jun 2009
    Posts
    7
    Rep Power
    0

    Default 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

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    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.

  3. #3
    arpitgadle is offline Member
    Join Date
    Jun 2009
    Posts
    7
    Rep Power
    0

    Default 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

  1. Checking the process's status in shared hosting
    By vivek1982 in forum Advanced Java
    Replies: 0
    Last Post: 01-29-2009, 07:39 AM
  2. Account mix problem
    By nihongbin in forum Threads and Synchronization
    Replies: 3
    Last Post: 12-10-2008, 06:05 AM
  3. Access Linux shared folder from Windows OS
    By nitinpjairaj in forum Networking
    Replies: 3
    Last Post: 08-26-2008, 07:14 PM
  4. how to access shared file/folder in LAN
    By ksheetiz in forum Networking
    Replies: 1
    Last Post: 05-24-2008, 05:54 AM
  5. creation of new folder in the mail
    By an8086 in forum Advanced Java
    Replies: 1
    Last Post: 07-15-2007, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •