This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I want to call the doPost() method with a link. I read the <A HREF="/webapps/servlet/servletName">Click here to show all users</A> called the doGet() method by default. When i click the link i want send parameters to the doPost. TO call the servlet i use the doGet() method wich has a link in the body to the same servlet in order to call the doPost() method. Thank you.
Assuming that you have an html form in your page, with a METHOD of POST, you can use javascript to submit it when you link is clicked. <a href="document.form['formname'].submit();">my link</a> Erick
Engin Okucu
Ranch Hand
Joined: Feb 09, 2002
Posts: 174
posted
0
Erick thank you. Can you write me the whole Javascript code because i have any knowledge about javascript.
Erick Jones
Ranch Hand
Joined: Jun 17, 2002
Posts: 38
posted
0
Erick Jones
Ranch Hand
Joined: Jun 17, 2002
Posts: 38
posted
0
Here it is again, and I have disabled the smilies...
Erick Jones
Ranch Hand
Joined: Jun 17, 2002
Posts: 38
posted
0
Ok, third time is a charm...had a typo in my last post
Erick Jones
Ranch Hand
Joined: Jun 17, 2002
Posts: 38
posted
0
one more time... <HTML> <BODY> <a href="javascript:document.forms['myForm'].submit();">test link</a> <FORM ACTION="/webapps/servlet/servletName" METHOD="POST" NAME="myForm"> </FORM> </BODY> </HTML>
Engin Okucu
Ranch Hand
Joined: Feb 09, 2002
Posts: 174
posted
0
Erik thank you very much. But i doesn't work. it shows me the body of doGet() and the doPost method is not called.
Engin Okucu
Ranch Hand
Joined: Feb 09, 2002
Posts: 174
posted
0
I found what it did not work because i must write : <a href="javascript ocument.myForm.submit();">test link</a> and not <a href="javascript ocument.forms['myForm'].submit();">test link</a> Thank you. it works now.