Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass parameter from JApplet to php file using POST method

 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have connected my JApplet with one php file, which gets the parameter from my applet and write it to MySQL database. Parameter is passed using textfield - user enters string and confirms it's choice clicking on Submit button.

I have made this connection using GET method, but I have to use POST method for sending parameter. I hope somebody can help me to do that.

Here is how I made connection:

In init() method I wrote:



link is a parameter which I defined in HTML file. It's value is http://localhost/subtest.php.

In my ActionPerformed method for button clicked I wrote:



Submitlink and fileToRead are strings.

Here is my readFile() method:



My subtest.php file looks like this:



Any help to use POST method instead of GET would be appreciated.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the applet side, see http://www.exampledepot.com/egs/java.net/Post.html for an example.
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote in my ActionPerformed method (for button clicked):



but I still don't have insert to the database. Where did I made a mistake?
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having an empty catch block is rarely a good idea, and definitely a bad one when dealing with I/O.

Does the request ever make it to your server code?
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, as far I know. There is no insert to the database (which is done by php file).
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, as far I know.

Make sure one way or another (maybe by adding logging statements to your server code).

And be sure to add logging to your applet's exception handlers as well.
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By server code: do you mean on php file? I am not familiar with PHP, so I am not sure I know to write logging statements there. Can you help me with that?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic