Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 10:07 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 5 posts ] 
Author Question
 Question subject: Accessing files in remote server (unix/windows) using JSP
PostPosted: Tue Apr 05, 2011 8:17 am 
Offline
Newbie
User avatar

Joined: Tue Apr 05, 2011 8:04 am
Posts: 2
Has thanked: 0 time
Have thanks: 0 time

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


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Accessing files in remote server (unix/windows) using JSP
PostPosted: Tue Apr 05, 2011 10:02 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 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;
    }
}


 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Accessing files in remote server (unix/windows) using JSP
PostPosted: Tue Apr 05, 2011 10:05 am 
Offline
Newbie
User avatar

Joined: Tue Apr 05, 2011 8:04 am
Posts: 2
Has thanked: 0 time
Have thanks: 0 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.


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Accessing files in remote server (unix/windows) using JSP
PostPosted: Wed Apr 06, 2011 9:35 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
why don't you use FTP.
Java FTP

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 5 posts ] 
Quick reply


  

 Similar topics
 Uplading Files Dynamically Using SSIS
 how to connect client on one machine with server
 java code for listing folder contents from remote folder
 client server client
 script for including files
 How to download and save .mov files from this website ?
 Ajax Source code to Suggest application with JSP Server side
 Hows does Windows find Java?
 RMI EXAMPLE FOR CLIENT SERVER ARCHITECTURE CODE ?????
 client server problem

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team