Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

copying images in client-server environment?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i transfer images from the client to the server using only core java (no jsp and servlets)?

the scenario is, the user uploads an image from the form, with the user specifying the location of the image like "C:\images\img.jpg", and i have to copy it from his computer to the server using http. i was playing around with URL and URLConnection but was having issues regarding the url, cause i can't work out a way to convert the image path to http path.

i know i'm doing it wrong and would like to know the best way to implement the problem.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which part are you trying to implement - the client or the server, or both?

When you say "no servlets, no JSP", yet you do want to use HTTP, what do you have on the server-side? Must be some kind of HTTP server. Can it accept HTTP file uploads?
 
lowercase baba
Posts: 13063
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm... I think I'll move this to the intermediate forum. this seems a little advanced for here.
 
Ralph Ching
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im implementing both client side & server side code for this problem. im using an mvc architecture where the jsp collects the data which in this case is the path to the image on the client's terminal, and the jsp & servlet transfers control to the model (a bunch of java files) and the model is supposed to perform the transfer of files.

the "methodology" for this project limits the way the jsp & servlets work in a way that those 2 does not do much server side other than passing the data to the model. im actually using JBoss for this project (so i think that is an http server).
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still confused ... is the client a browser or a Java program?

For a browser client, you can put a file upload control in an HTML form:

When the user submits the form, the browser sends a multi-part MIME request to the server. This is all to HTTP standards, but it's a bit tricky to read these requests on the server. Fortunately there are libraries around to do the job for you when the form posts to a servlet.

For a Java client, you can use sockets or a library for FTP. See the Sun Networking Tutorial for a good start on sockets.
 
reply
    Bookmark Topic Watch Topic
  • New Topic