aspose file tools*
The moose likes Beginning Java and the fly likes Connecting from another computer to get files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Connecting from another computer to get files" Watch "Connecting from another computer to get files" New topic
Author

Connecting from another computer to get files

Ralph Ching
Greenhorn

Joined: Jul 18, 2006
Posts: 15
hello, i've some issue setting up connecting between 2 PC's (in the same room) for a client-server experiment. i would appreciate any comments for this problem.

my logic for the server-side is i have a servlet in a WAR file that accepts request from a client(to retrieve the file requested by the client). the file is broken down into pieces by using FileInputStream, and then sent to the client by using HttpServletResponse.

on the client side, i am connecting thru the server using URL class, opening a connection then reading whatever the server sends.

for some reason, whenever the client asks for a file, the server sends a corrupt file (unreadable). why is this occuring? am i using the wrong approach for this problem (should i use Sockets or RMI instead)?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Without seeing your code we're only guessing, but I can offer some suggestions.
Does your URL work in a browser and produce a workable file?
Do you have common IO pitfalls in your code, in particular, this one or this one?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

for some reason, whenever the client asks for a file, the server sends a corrupt file (unreadable). why is this occuring? am i using the wrong approach for this problem (should i use Sockets or RMI instead)?


First check if Joe's suggestion solves your problem.
Then what type of file are you sending?, I would recommend to test with text files first, they are the simplest ones to start with.

And if your experiment does not require web application in particular, then I would suggest using sockets, its pretty simple than web application.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting from another computer to get files