Results 1 to 17 of 17
  1. #1
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default Upload/download a file to/from server

    Hey :)

    I'm new to java networking and I'm building a app where I need to upload/downlad a file to/from server.

    How can I upload and download files from a web server? ftp!?!?

    I'm not building a web application(servlets, jsp etc)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    FTP can be used for uploading and downloading files to/from a FTP server.
    There are probably third party packages that handle that protocol. Or you could write your own FTP code.
    Try Google

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Or at least search on the forum. Quite similar thread are there, you can find in our forum.

    Quote Originally Posted by karq
    I'm not building a web application(servlets, jsp etc)
    Then what? Try to explain your question more clearly, some people can be confused.

  4. #4
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Or at least search on the forum. Quite similar thread are there, you can find in our forum.



    Then what? Try to explain your question more clearly, some people can be confused.
    My app is like a sticky note, where you can add notes. Right now I'm trying to build a web extension. I dont have my laptop allways with me, so I'm building a web extension so that I can add things to the list with my mobile phone.

    The app should send/receive note files from the server.

    If you want you can get my first build from here http://karq.planet.ee/blog/wp-conten...nload.php?id=1

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    Why does your code try to access the SystemTray? I tried to run it with some security and I get: access denied (java.awt.AWTPermission accessSystemTray)

    Also it says: Can't read input file!

  6. #6
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Why does your code try to access the SystemTray? I tried to run it with some security and I get: access denied (java.awt.AWTPermission accessSystemTray)

    Also it says: Can't read input file!
    weird, I tried it on several pc's and it worked. It has a systemTray function, you can minimize it to tray.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    I ran it with some security to limit its actions.
    What permissions does it need to execute?

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Fine, I can see in the my tray and I have an idea what you want to do. But my concern is that why you want to upload/download to/from the server. If I'm right you just want to access the task.do file to keep records of the items (task actually). So to do that uploading/downloading the file is not a good choice at all. Just implement a web service to process the data on that file, keep the file in the server (not in the local machine as your example does) and in both desktop and mobile application access that file. Web service can be use in two cases.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Norm View Post
    I ran it with some security to limit its actions.
    What permissions does it need to execute?
    It works fine for me too Norm.

  10. #10
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Fine, I can see in the my tray and I have an idea what you want to do. But my concern is that why you want to upload/download to/from the server. If I'm right you just want to access the task.do file to keep records of the items (task actually). So to do that uploading/downloading the file is not a good choice at all. Just implement a web service to process the data on that file, keep the file in the server (not in the local machine as your example does) and in both desktop and mobile application access that file. Web service can be use in two cases.
    yes, that would be greate, but if I dont have internet connection, then the list will be unavaliable.

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Okay, in simple terms without a connection to the WAN (actually the internet) how can you connect two devices? You can't. In that sense you've to maintained two application separately, and at the beginning you have to sync your data file. Still you need a connection to the internet, but no need to be both devices connect to that WAN.

  12. #12
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Most of the time I will have connection, but if I dont I then I would like to have the most recent list avaliable on my pc. Basiclly I still have to download the file on my pc.

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    My advice is not to download the file, to sync the file only download the content to the local device, just the content. Through a webservice as a XML stream, much safer much effective.

  14. #14
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    My advice is not to download the file, to sync the file only download the content to the local device, just the content. Through a webservice as a XML stream, much safer much effective.
    So basically I have to replace my task.do file with a xml file and then make a stream from the server to my local machine?

    I made some research on web services, tell me if i'm wrong, but if I implement a web service to the project, then it will run on tomcat, so if I export the project into a runnable jar, will the web service still work if I dont have tomcat installed and the task file is just on a apache web server?

    I dont have much knowledge about servlets, tomcat and how they work. Example: If I upload a php project to a apache web server, then it will work there, but if I upload a java EE(jsp, servlets) project then it propably will not work(javaEE project need tomcat for running?!!?!)?
    Last edited by karq; 08-23-2010 at 06:31 PM.

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Web service should run in the server, so that you've use kind of web server like tomcat, etc. Without that how you can deploy it, just think that web-service also kind of web site, but the different is you are heavily use it o transfer the data. It dosen't matter that your project is J2EE, J2SE, etc... Each has quite similar technologies, means that underlying concept is not differ at all. You can use webservice from your mobile application, desktop application, etc.

    And also for transfer data I didn't told that XML is the ONLY solution. It's one of the best technology to use, secure and reliable. You can define your own protocols and pass data in different formats too.

  16. #16
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Maybe someone can give me some good web service tutorial links?

  17. #17
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Download File from the server
    By ersachinjain in forum Networking
    Replies: 10
    Last Post: 04-22-2010, 04:14 AM
  2. Upload war file on server
    By sandeeprao.techno in forum Advanced Java
    Replies: 2
    Last Post: 12-16-2009, 10:55 AM
  3. how to download file from ftp server
    By santhosh_el in forum Networking
    Replies: 0
    Last Post: 11-19-2009, 06:01 AM
  4. :large file upload to server(chunk upload)
    By tommy_725 in forum Networking
    Replies: 0
    Last Post: 10-16-2009, 12:21 AM
  5. upload and download file using servlet
    By amit_m04 in forum Java Servlet
    Replies: 1
    Last Post: 09-27-2009, 03:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •