• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how call doPost()  RSS feed

 
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.
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!