File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes generate a text file in another server ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "generate a text file in another server ??" Watch "generate a text file in another server ??" New topic
Author

generate a text file in another server ??

Sylvia Wang
Ranch Hand

Joined: Apr 10, 2001
Posts: 53
Hi, dear all
Here is my problem:
I need a web page, to output some list,if the user feel OK after reading, he/she click on a button in the web page, then my servlet should save this list into a text file and transfer to another NT server's directory.
I'm using Websphere in Unix, I feel it won't be an easy task to fulfil, HELP PLEASE !
Many many thanks.
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
the easiest solution would be to set up a server of some sorts ont he NT machine and have it accept files and store it on its file system independently of the web server.
otherwise, I've never tried accessing network resources but - the NT system mustnt be set up with NTFS since the only linux driver for NTFS i know is currently read only (link below). The link includes other FS drivers for NT from linux.
http://www.tldp.org/HOWTO/Filesystems-HOWTO.html


chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
Sylvia Wang
Ranch Hand

Joined: Apr 10, 2001
Posts: 53
How about through FTP ? my NT server is a FTP client.
Can servlet call an Unix script ? in the Unix script I can FTP the file from Websphere server to NT server.
Did anybody tried to call an Unix script from servlet ?
Thanks.
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
there are FTP APIs that you can use to directly FTP stuff rather than call a script which would probably be a better idea, but..
you can call scripts directly using:
Runtime.exec(String command)
to run the shell script without arguments, which will mean always putting the file on the local system somewhere the script knows to find it, or alternatively:
Runtime.exec(String[] cmdarray);
to run a command (the first array item and its arguments as the remaining items and so on
you may have to set appropriate permission (filepermission execute) if you have a security manager installed
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Another alternative would be to transfer the information across the network asynchronously, using something like JMS.
Fire off a message and have a listener on the NT machine read the message and write the file appropriately. Using client acknowledgements, you can build some transactionality around the process should the writing to file fail for any reason.
Just another option...
Simon
Sylvia Wang
Ranch Hand

Joined: Apr 10, 2001
Posts: 53
Thanks Chanoch and Simon for your helpful suggestion.
I've tested out the FTP way by using sun.net.ftp, it's simple and work fine for text-base files, so I'll go for that.
However when I searching the information about sun.net.ftp everywhere in the web, the news saying Sun is not supporting this package and will be removed from JDK soon, is it true ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generate a text file in another server ??
 
Similar Threads
To author
DropDown List Problem : file system
Design choice for dispatching request to view
What to Do If I Do Not Want Text to be Hard Coded in HTML?
Uploading Files in jsp