Results 1 to 8 of 8
  1. #1
    sanoj_av is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default Write file to webserver from an Applet

    Hi, I am new to Java,

    I have simple applet which works fine. I just want to show some information which are enetred by some users to all the users of the applet. For that I use a small light weight DB (sqlite version 3). I am creating the connection as follows
    Connection conn =DriverManager.getConnection("jdbc:sqlite:"+System .getProperty("user.dir")+"\\GT.db");
    Now my problem is that the applet create the GT.db file in the client machine as the System.getProperty("user.dir") return the user directory on the client , not on the server. Hence i am not able to achieve what I want. How do I save the file on the web server instead of the client ?
    I am using a signed applet. I dont have much control over the web server to install programs or add server side processes; but I can upload files. I googled and found that an applet can read and write files to the host where it is coming from. If so how do i do it? can any one help me please ?

  2. #2
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,185
    Rep Power
    20

    Default

    If you want all the users to see data from each other then you need your db on the server.
    Second, you will either have to expose that db through a port (I don't know sqlite, so can't say if that's doable), or have some code (servlet, php, whatever) that will do the accessing and your applet will then make http calls to this.

  4. #4
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    So you mean uploading ?

  5. #5
    sanoj_av is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default

    Thanks Tolls & cselic for your valuable replies. I solved it by using one server side script in PHP which talks to the database and call that PHP from my application by using URLConnection class.


    Thanks
    Sanoj

  6. #6
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Exclamation

    Thanks Tolls & cselic for your valuable replies. I solved it by using one server side script in PHP which talks to the database and call that PHP from my application by using URLConnection class.
    Much surprised to see PHP advices on Java forum :confused:

    Now my problem is that the applet create the GT.db file in the client machine as the System.getProperty("user.dir") return the user directory on the client , not on the server.
    Oh... It is not a problem but an applet reality cause applets are client apps ;)
    To avoid that I recommend just use a servlet for your applet because servlets are really can get access your server side as a desktop app ;)
    So write a servlet doGet method and place your code in it like a

    Java Code:
    Connection conn =DriverManager.getConnection("jdbc:sqlite:"+System .getProperty("user.dir")+"\\GT.db");
    then connect your applet to your servlet and that's it :) it is a simpliest way to solve your problem I guess. If problem stays report
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,185
    Rep Power
    20

    Default

    He solved his problem.
    He has the applet talking to a server that does the work for him.
    Who cares whether that server code is written in PHP, Java, or Flingleplap?

  8. #8
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Talking

    Quote Originally Posted by Tolls View Post
    Who cares whether that server code is written in PHP, Java, or Flingleplap?
    Java fans, pal :rolleyes:
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

Similar Threads

  1. Applet Server Write Permission
    By Look2Logic in forum New To Java
    Replies: 0
    Last Post: 04-13-2010, 10:21 PM
  2. Applet: Can't write a file
    By DaanDwars in forum Eclipse
    Replies: 6
    Last Post: 09-03-2009, 02:26 PM
  3. Signed Applet to write on LPT1 port - permission error
    By ConvoyTh in forum Java Applets
    Replies: 0
    Last Post: 07-02-2009, 11:56 AM
  4. Replies: 5
    Last Post: 02-05-2009, 11:28 AM
  5. Replies: 1
    Last Post: 10-21-2008, 10:21 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
  •