Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 4th, 2006, 11:53 AM   #11
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
Wouldn't that be for a GET request Game_Ender?

By the way, it seems like people could easily abuse this and put whatever they wanted on the high-score list.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jul 4th, 2006, 1:37 PM   #12
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
It could quite possibly be a GET request, I know you can do html forms through both a POST and a GET and I don't know the exact differences between the two. Html is not my strong suit so you are probably right. That is why I advised him to do some reading on html forms, I know where to point but not exactly what to say.
Game_Ender is offline   Reply With Quote
Old Jul 4th, 2006, 1:46 PM   #13
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You might want to look into JSP (Java Server Pages).
titaniumdecoy is offline   Reply With Quote
Old Jul 4th, 2006, 2:12 PM   #14
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Quote:
Originally Posted by uman
By the way, it seems like people could easily abuse this and put whatever they wanted on the high-score list.
They won't be able to see where the data is being sent. Its actually on a completely different domain than where the Java applet is being used. The Java applet is loaded on my "cogeco.ca" web space, while the highscore is sent to a remote PHP server at "arbornet.org" thus, the user doesn't know where the highscores would be found.

The problem is getting a string "10294059" for instance, to the action.php program. Somehow by sending a string from the java applet to the URL.

import java.awt.*;
import java.io.*;
import java.applet.*;
import java.net.*;

class SaveData extends Applet
{
    public void init ()
    {
        String line;
        URL url = null;
        try
        {
            url = new URL ("http://m-net.arbornet.org/~eric/action.php");
        }
        catch (MalformedURLException e)
        {
            System.out.println ("Malformed URL ");
            stop ();
        }

    }
}

that red writting is the URL. So how do I send a string to this site?
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old Jul 4th, 2006, 2:27 PM   #15
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 748
Rep Power: 3 Jimbo is on a distinguished road
I don't know how to make Java and PHP interact, but I can explain the GET vs. POST a little. These are the two methods through which forms are submitted (hence the method="get" or method="post" attribute).

GET parameters are simply appended to the url after a '?' and are separated by '&'. For instance, if a url was
http://someplace.com/aPage.php?player=someone&score=10294059
the receiving page would have $_GET["player"] == someone and $_GET["score"] == 10294056. However, as mentioned this is not very secure. A user could easily put in whatever values they wanted to send to the page. On the other hand, GET variables can be bookmarked; this doesn't pertain to your case, but it's something to considter sometimes.

POST variables don't show up in the URL. I'm actually not sure where they're sent, but it is more difficult to change them. Of course, they arrive to the PHP page in $_POST, too. Pages relying on POST variables cannot be bookmarked since you can't set the values by hand (or very easily at least - I think there's some browsers that'll allow a user to set POST variables).

HTH
Jimbo is offline   Reply With Quote
Old Jul 4th, 2006, 3:26 PM   #16
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I'm curious as to why you are using Java (the game itself?). However, there are ways to interact between Java and Javascript. The Javascript could conduct the appropriate request, and there you go, Aunt Gertie's your uncle.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 4th, 2006, 3:34 PM   #17
nemesis
Programmer
 
nemesis's Avatar
 
Join Date: Aug 2005
Location: Bristol, England
Posts: 71
Rep Power: 3 nemesis is on a distinguished road
Send a message via MSN to nemesis
Am i the only one who is wondering who Aunt Gertie is and why she is my uncle?

She was refered to numerious times in your openBSD thread. I guess i must have missed something. lol.
__________________
Bite My Shiny Metal Ass
nemesis is offline   Reply With Quote
Old Jul 4th, 2006, 3:53 PM   #18
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 3 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
I think Aunt Gertie is meant to represent a standard computer user. I may be wrong.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Jul 4th, 2006, 5:31 PM   #19
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
the Java Applet is the game itself which takes care the game and sending info to a web page "action.php". Javascript isn't an option, unfortunately.

The method I would have to use is the "post" method. "Figure A.1" is the html page that would normaly send the score. However, instead of telling the user to "go to this website and enter your score", I want to do it for them. Thus, my java applet must do this. Interacting with the PHP program (on the server) shouldn't be a problem. All I have to do is basically send the score data to the site.

You guys are telling me to send the info to the url. Well the url is similar to "http://m-net.arbornet.org/~eric/action.php" and I'm not sure exactly what I'm supposed to do with the url once I've formed it. So far, I use the url class to form the url with
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
...
url = new URL ("http://m-net.arbornet.org/~eric/action.php");
// String score = 1012345";
However, once this is done I don't know what method to use to send the score to the url
Any ideas?


Figure A.1
<html>
<body>
<form action ="action.php" method="post">
<p>Your name: <input type="text" name="strname"/></p>
<input type="submit"/>
</body>
</html>
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old Jul 4th, 2006, 6:47 PM   #20
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The fact that Java is required (because of the game) doesn't mean you can't make a Javascript/Java object, access it from both sides, and use it strictly as a communication mechanism between the applet and the page. It's been over three years since I did this, but if you have the O'Reilly book on Javascript you'll find it covered to some extent there. I had a similar situation with a web casino. No way Javascript could produce things like a slot machine's spinning wheels in sufficient time (although it was fine for keno).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC