Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

frame to servlet communication..

 
karan, chopra
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers,
i am trying to make a frame communicate with a servelt.i have 2 buttons in my frame,what i want is that when i press the first button then the frame should talk to the servlet and the servlet should execute its doGet method and pass a vector containing some values to the frame..THIS PART WORKS FINE AND THE FRAME DOES GET THE VECTOR,I HAVE CHECKED IT..but what i want is that when the user clicks the second button then the frmae should pass a vector to the servlet and servlet should read the vector using its doPost method.BUT THIS IS THE PART THAT IS NOT WORKING..basically as i have understood from running the program,the doPost method never gets executed..why is this so?i mean how can i make sure that on the click of a certain button in the frame the doPost of servlet gets executed?please helpp..its urgent..i would appreciate your help..
regards
karan
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you don't give any code, it is hard to say. However - in order to make a URLConnection do a POST request, you have to use a method that is in the HttpURLConnection class. It turns out that if you create a URL using "http://whatever" what you get with openConnection is really
HttpURLConnection hc = (HttpURLConnection)url.openConnection();
And (this is the important part) you can then:
hc.setRequestMethod("POST");
Which should result in a request going to doPost
Bill
 
karan, chopra
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi william,
i have mailed u the java files corresponding to my problem at the email given in your profile here..please take a look at it and advice me about the solution,i would appreciate it.
regards
karan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic