You can do this by using Javascript.

<form name="postform" method="POST" action="someservlet">
<input type="hidden" name="name1" value="value1">
<input type="hidden" name="name2" value="value2">
</form>

<a herf="javascript:document.postform.submit();">A link that posts</a>

I think that

<a href="" onclick="document.postform.submit();">A link that posts</a>

should work also.

This code may not be perfect, I haven't tested it, but it should point
you in the right direction.

Carles


Sanjay Garg wrote:
>
> Hi,
>
> I am trying to invoke doPost() method of a servlet from a hyper
> text link in my JSP, but it is always calling doGet(). I am doing
> different stuff in each method, so can't do a doPost() within
> a doGet(). Is there a way I can force a method type for my servlet
> when invoked from a link.
> In HTML Unleased book it is mentioned that if link is with a
> <FORM> </FORM> and the method defined is "POST" then doPost()
> (of CGI program) would be called. But link is not exactly a form
> element , so I am not sure how it would work. Anyway it is not
> working for my servlet. Is there any setMethod (like request.getMethod())
> which I could use.
> Of course I can always create 2 different servlets. Is this the
> standard/recommended practice, not to have different functionality
> for doGet and doPost .
> BTW, I running Websphere 2.0 server on NT.
>
> Would appreciate any help.
> Sanjay
>
> -----
> Sent using MailStart.com ( http://MailStart.Com/welcome.html )
> The FREE way to access your mailbox via any web browser, anywhere!
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to