• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connecting from another computer to get files

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic