Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Java and Web Pages (http://www.programmingforums.org/showthread.php?t=10620)

Eric the Red Jul 4th, 2006 9:20 AM

Java and Web Pages
 
I've got this java program which needs to be able to enter data in a textbox on a web page. Shown below,

http://home.cogeco.ca/~ebelec/pic/ex2.jpg


Is there a way that I'd be able to enter data in the textBox (marked 'something') and then hit the "Submit Query" button without the user seeing me do this?

I'm doing this because on that web page a PHP program will run and calculate a highscores list for my game.

Does Java have this sort of capability?

uman Jul 4th, 2006 10:23 AM

Learn the name of the fucking programming language you're using before you ask questions.

Eric the Red Jul 4th, 2006 10:25 AM

Quote:

Originally Posted by uman
Learn the name of the fucking programming language you're using before you ask questions.

What the heck is your problem? You mean Java?

coldDeath Jul 4th, 2006 10:38 AM

I think uman is refering to the fact that you may be confusing Java and JavaScript, two completely different languages.

Eric the Red Jul 4th, 2006 10:41 AM

Quote:

Originally Posted by coldDeath
I think uman is refering to the fact that you may be confusing Java and JavaScript, two completely different languages.

I'm not confusing the two actually. In fact, this all has to be done with a java applet.

nemesis Jul 4th, 2006 10:53 AM

If your using a java applet then surely this would not be difficult. You would have the text box and button in the applet, then you can do what ever you want with them.

But if you want php and java to send data to each other then i think its probably impossible. But i could be wrong.

I think you should go find out what java applets can really do, and then find out that there are easier ways. I dont quite understand why you want to do what you are doing? Maybe if you explain with some code and more detail people wount swear at you.

uman Jul 4th, 2006 11:09 AM

Sorry, I assumed you were confusing Java with JavaScript like countless retards who come in here. My apologies.

Eric the Red Jul 4th, 2006 11:22 AM

Not a problem.

Here's the html code for the page:
:

<html>
<body>
<form action ="action.php" method="post">
<p>Your name: <input type="text" name="strname"/></p>
<input type="submit"/>
</body>
</html>


Here is action.php called by the main page (which is irrelevant to the java program) but you asked for it here it is.
:

html>
<body>
<?php
$strname=$_POST['strname'];
print "you typed:$strname";
?>
</body>
</html>


Game_Ender Jul 4th, 2006 11:27 AM

You want to take a look at how HTML forms work. When you hit the submit button the information in the textbox is packed into a url and sent to the webserver by your web browser. All you have to do is make that URL programatically instead of having the web browser generate it.

I am not sure but I think the URL looks something like below
:

http://www.mywebpage.com/mypage?myTextField=10
Just do a little reading on how html forms work and you should be able to figure out how the information should be placed into the url.

Edit, I saw your new post: What you have to do is submit an html POST request and I believe the url should be:
:

http://www.thewebpage/page?strname=198
Where 198 is replaced with the score you want to manipulate.

EDIT: Updated the the last edit for clarity.

Eric the Red Jul 4th, 2006 11:30 AM

Thanks Game Ender. I'll try it out.


All times are GMT -5. The time now is 2:58 PM.

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