File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting from another computer to get files

 
Ralph Ching
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic