Total members 11890 |It is currently Thu Apr 25, 2024 3:04 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi All,

Good morning to all.

I am doing a project for monitoring OS of different system (Unix and Windows) using JSP.

I want to know if you can help me in writing code for accessing file in remote server in JSP. I am struggling hard :banghead: for this from long time, but no success :cray:

Also can i know if i can execute OS commands remotely (Unix/Windows where jdk is only installed) from JSP server ( where tomcat and jsp application is running)

Thanks in advance. :gOOd:

Regards,
Kishore




Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

code help .
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mailtest.customgui;

import java.io.*;
import java.lang.String;
import java.io.File;
import java.util.*;
import java.util.List;
import java.lang.*;
 
public class RemoteFileTest 
{

    private File fileObj;
    private Map mapfiles;

    public RemoteFileTest() {
        fileObj = new File("\\\\IPorComputerName\\path");

        mapfiles = new HashMap();
        mapfiles=printFileInfo(fileObj, mapfiles);
        Iterator filesIterator = mapfiles.keySet().iterator();
        while (filesIterator.hasNext()) {
            String filePath = (String) filesIterator.next();
            String fileName = (String) mapfiles.get(filePath);
            System.out.println("File name is " + fileName);
            System.out.println("File path is " + filePath);
        }
    }

    public static void main(String args[]) {
         new RemoteFileTest();
    }

    /*
     *
     * Print the content of path , and return a map
     * of all files in it .with path and name.
     */
    public Map printFileInfo(File fileObj, Map filesMap) {
        File[] files = fileObj.listFiles();
        // If the current is directory.
        if (fileObj.isDirectory()) {
            // list for files inside the this directory.
            for (int i = 0; i < files.length; i++) {
                printFileInfo(files[i], filesMap);
            }
        } else {
            // get the information of fileObj , path is key,name is value to map.
            String path = fileObj.getPath();
            String name = fileObj.getName();
            filesMap.put(path, name);
        }
        return filesMap;
    }
}


 


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

HI,

:clapping: :clapping: :clapping:

Thanks for the reply :gOOd:

But What if i want to read the file without a share.. since i have to read files from UNIX, using samba is restricted in some of servers, especially production servers. :cray:

Kindly suggest.


Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

why don't you use FTP.
Java FTP

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 5 posts ] 

  Related Posts  to : Accessing files in remote server (unix/windows) using JSP
 Sql server or windows server question?     -  
 FTP WITH WINDOWS SERVER 2003     -  
 Fax Services Access in Windows Server 2003     -  
 copy files from applet server to client     -  
 Get disk free space for Unix-Linux in php     -  
 php Accessing a Property from Within a Method     -  
 Dynamically Setting and Accessing Variables     -  
 update an xml file with jaxb and accessing to its elements     -  
 get Remote host     -  
 Remote EJb Connections     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com