Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

copying images in client-server environment?

 
Ralph Ching
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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).
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic