This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Servlets and the fly likes how call doPost() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how call doPost()" Watch "how call doPost()" New topic
Author

how call doPost()

Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
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

Joined: Jun 17, 2002
Posts: 38
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
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
Erick Jones
Ranch Hand

Joined: Jun 17, 2002
Posts: 38
Here it is again, and I have disabled the smilies...
Erick Jones
Ranch Hand

Joined: Jun 17, 2002
Posts: 38
Ok, third time is a charm...had a typo in my last post
Erick Jones
Ranch Hand

Joined: Jun 17, 2002
Posts: 38
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
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how call doPost()