Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how call doPost()

 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Erick thank you.
Can you write me the whole Javascript code because
i have any knowledge about javascript.
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is again, and I have disabled the smilies...
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, third time is a charm...had a typo in my last post
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic