Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-12-2008, 01:36 AM
Member
 
Join Date: Apr 2008
Posts: 1
phani is on a distinguished road
To transfer a file from client to server
I am new to Java and would like to know how to transfer a file from cclient to server.I need to transfer the whole file and not the contents. Like I might need to transfer an .xls file to server and can open it
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-16-2008, 02:39 AM
Member
 
Join Date: Apr 2008
Posts: 4
dream_noir is on a distinguished road
There are lots of ways to transfer a file from a client to a server and depending on the purpose and what your working with you can probably narrow it down to what suits you best..

Are you writing both the client and server software? If you are, you can do it however you like, if not you'll have to find out what protocols the application your trying to send/get a file from uses and use that.

Obviously you'll have to send it over the network, if your writing both the client and server and what to do all the dirty work yourself you should look at Sockets. There is a tutorial on the java website. Basically all you have to do is make a TCP connection between the client and server (using Sockets). You can then either come up with your own protocol or implement a protocol meant for transfering files, like FTP.

If you just had to send one file a simple protocol could be something like this:

Client: connect to server and say "hello"
Server: respond with "hello"
Client: sends filename to be sent
Server: responds "okay filename" or maybe "no filename" if it won't accept it
Client: opens a filestream of some sort and sends the file bit by bit.
Server: after file succesfully saved says "received filename"
Client: "good quitting"
Server: "quitting"

You could make it even simpler than that, but that is the basics.

If you don't want to have to deal with that or your interfacing with an FTP server you didn't write on one end. There are some implementations your free to use in Java at this link: Java FTP Tips

I'd take a look at that page, the java page on Sockets, and lookup some basic information on TCP (transmission control protocol) so you can figure out what is going to best suite your needs.

Last edited by dream_noir : 04-16-2008 at 05:35 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how client know what kind of server lemur Networking 1 04-05-2008 11:32 PM
Copy a .swf file from server side to client using signed applet Imoracle Java Applets 0 01-28-2008 01:39 PM
Identify Client in Socket Client Server Application masadjie Networking 1 12-20-2007 10:18 AM
send file via client - server model spasavvas Networking 3 08-14-2007 08:27 PM
Problems with client and server Albert Advanced Java 2 07-02-2007 07:07 AM


All times are GMT +3. The time now is 06:21 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org