• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Pass parameter from JApplet to php file using POST method

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic