Results 1 to 8 of 8
- 04-20-2010, 09:22 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
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 ?
- 04-20-2010, 11:42 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
I think this example would be helpful:
Java HTTP example - Reading and writing to an HTTP server | devdaily.com
- 04-20-2010, 11:47 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 04-21-2010, 05:19 AM #4
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
So you mean uploading ?
- 05-11-2010, 11:21 AM #5
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
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
- 05-12-2010, 03:10 AM #6
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Much surprised to see PHP advices on Java forum :confused: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.
Oh... It is not a problem but an applet reality cause applets are client apps ;)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.
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
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 reportJava Code:Connection conn =DriverManager.getConnection("jdbc:sqlite:"+System .getProperty("user.dir")+"\\GT.db");If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
- 05-12-2010, 09:19 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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?
- 05-14-2010, 03:39 AM #8
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Similar Threads
-
Applet Server Write Permission
By Look2Logic in forum New To JavaReplies: 0Last Post: 04-13-2010, 09:21 PM -
Applet: Can't write a file
By DaanDwars in forum EclipseReplies: 6Last Post: 09-03-2009, 01:26 PM -
Signed Applet to write on LPT1 port - permission error
By ConvoyTh in forum Java AppletsReplies: 0Last Post: 07-02-2009, 10:56 AM -
How to read and write to a file without taking out the comments in the file
By MAGNUM in forum New To JavaReplies: 5Last Post: 02-05-2009, 10:28 AM -
Is Apache Tomcat webserver redirecting http request to another webserver
By barunva in forum Web FrameworksReplies: 1Last Post: 10-21-2008, 09:21 AM


LinkBack URL
About LinkBacks


Bookmarks