Results 1 to 5 of 5
  1. #1
    sdkrp is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Write Log File On Server Side

    Hi Everyone,

    i have tried to write the log file on server side using java program from client machine. Following is file writing program,

    String path=new AccessRights().getPath();
    path=path.substring(1,path.indexOf("WEB-INF"));
    path +="database.properties";
    String DATE_FORMAT = "yy-MM-dd";
    java.text.SimpleDateFormat sdf =
    new java.text.SimpleDateFormat(DATE_FORMAT);
    Calendar c1 = Calendar.getInstance();
    Properties props = new Properties();
    InputStream in = new FileInputStream(path);
    props.load(in);
    String dir="\\\\ServerIP\\C$\\IntruderLogFiles";

    System.out.println("dir: sys.java-->"+dir);

    if(!dir.equals(null)){
    System.out.println("string string string-->"+string);
    File file = new File(dir);
    System.out.println("string string string1111111111-->"+string);
    file.mkdirs();
    System.out.println("string string string-222222222222222->"+string);
    String outputfileName= File.separator+"NIC-INTR-log "+sdf.format(c1.getTime())+".txt";
    System.out.println("string string string-3333333333333333->"+string);
    File ff=new File(dir,outputfileName);
    System.out.println("string string string-44444444444444444444444->"+string);
    ff.createNewFile();

    FileWriter fw=new FileWriter(ff,true);

    fw.write(string);
    fw.flush();
    String separation=System.getProperty("line.separator");
    fw.write(separation);
    fw.flush();
    fw.close();
    }
    }

    i called this java class from another java class. i got the following error while running ,

    File name: sys.java-->Access is denied.


    please help me to rectify it.

    thanks,
    Dhanushkodi

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,764
    Rep Power
    5

    Default Re: Write Log File On Server Side

    Seems like your application doesn't have filesystem rights to access a particular file or directory.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    sdkrp is offline Member
    Join Date
    Sep 2013
    Posts
    4
    Rep Power
    0

    Default Re: Write Log File On Server Side

    No, i have created the folder manually in server and i make it as shared one and gave all the access rights to that folder by all the users available on the network.

    So please suggest and clear this issue.

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,764
    Rep Power
    5

    Default Re: Write Log File On Server Side

    But access is still denied to "something". You have to figure out what that something is. And since only you have access to your system, that job stays with you.
    Last edited by gimbal2; 09-12-2013 at 12:41 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default Re: Write Log File On Server Side

    Also I would suggest improving your exception handling.
    You should, at the least, have a stack trace in there so you know exactly where this error was thrown from.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Applet reading/writing to server side file
    By JamieG in forum Java Applets
    Replies: 3
    Last Post: 09-10-2011, 10:25 PM
  2. Replies: 9
    Last Post: 09-01-2009, 07:17 PM
  3. updating server side file using java bean
    By tskarthic in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-30-2009, 02:53 PM
  4. How to open a file located in server from client side
    By Malathi in forum Web Frameworks
    Replies: 4
    Last Post: 04-20-2009, 09:10 PM
  5. Replies: 2
    Last Post: 10-05-2008, 06:13 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
  •