aspose file tools*
The moose likes Applets and the fly likes No connection to database from JApplet on Web page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "No connection to database from JApplet on Web page" Watch "No connection to database from JApplet on Web page" New topic
Author

No connection to database from JApplet on Web page

maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
Hello!

I have created JApplet and placed it on the Web page. In applet, I have slider and submit button to confirm user's choice on slider. That choice (slider's value) should be written in the database. When I run the Applet Viewer in NetBeans everything works just fine (value is recorded in the database). For the Web page, I created a php file (and named it sub.php) which looks like this:
Hint: ime is the database's field name

I made this file to act as intermedier between the database and Web page (value from applet on Web page should be written in it and then read from the database). I wrote this code for connecting to that file in the applet:


It is written "localhost" here because I use XAMPP as local server and put jar, classes and html file in it's htdocs folder. Then I run the applet's html file localy in my browser.




Hint: potvrdi is my botton's name



If you have read all this, I'm very grateful for your patience and I hope you have any idea to help.
maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
I have succeed to make connection. I wrote:


When I start Web page, it inserts 2 values in the database - 1st is the initial slider value (it writes 500 because it is my initial slider value) and 2nd is the regular value which it gets when I choose value on slider and press submit button. Any idea how to change this method to prevent recording initial value when I start the Web page...?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

A boolean variable?

Set it to false when the applet is starting (and you don't want to execute that code). Set it to true later (when you do want to execute that code). Test the variable before executing that code.
maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
How to make that, how to set it false and later true? I wrote the method in the previous post. I think that problem is in the condition if (prHtml != null) fileToRead = new String(prHtml); but I don't know how to set it for my needs. Any idea...?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No connection to database from JApplet on Web page