aspose file tools*
The moose likes Applets and the fly likes Applet and PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet and PHP" Watch "Applet and PHP" New topic
Author

Applet and PHP

Lee Stee
Greenhorn

Joined: Mar 24, 2009
Posts: 5
I have a question about java Applets and PHP.

I have an applet written and deployed that collects information from the user. I need to export that information (19 numeric fields) to a PHP page that processes it. I have tested the PHP page and it works well with a standard HTML POST form. The java applet however, will not complete the process with the PHP form. I pasted the code below.



I found this code online and I think I'm getting closer, but nothing is happening. Does anyone know what is going on here?

Thanks, I really appreciate it!

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41884
    
  63
Welcome to JavaRanch.

Does "nothing is happening" mean that the request doesn't reach the server?

The string-to-byte-to-string conversion looks suspect. What's more, the parameters should be URL-encoded, unless you can be certain that that's not needed. Here's an example of a POST using the URLConnection class.


Ping & DNS - my free Android networking tools app
Lee Stee
Greenhorn

Joined: Mar 24, 2009
Posts: 5
Thank you for the reply. I actually found my error was in the PHP file. The PHP file always checked to see if SUBMIT was set because I always test PHP though simple HTML forms that use submit. So, it wouldn't check anything since $_POST('Submit') was never set. Below is the final code I ended up using. I post this just in case anyone doing searching the web comes across this.

Thank you again for your help.



And the PHP file is shown below. It insert the values into a database recieved from the applet. All this code was simplified since it used to use over 100 variables to input. However, for the sake of anyone who is searching for ideas and possible solutions, this is much easier to look at and try out!

Alexis Michael
Greenhorn

Joined: Mar 29, 2009
Posts: 9
what's the speed of this operation compared to having the applet connecting directly to the database through JDBC ( not having in mind the security restrictions imposed on the applet)?
Lee Stee
Greenhorn

Joined: Mar 24, 2009
Posts: 5
The direct connection to the database is probably a bit faster, but nothing noticable from my end. My issue was that I couldn't direclty use JDBC because the host didn't allow it on their website. I think the streaming connection to the database would be more secure too. But like all software, you have to work with you got!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Applet and PHP