You are correct that normally you would user <form method=post> but this
isnt possible via a hyperlink where your only real choice is to do it as <a
href="http://www.blah.com?param1=value1¶m2=value2. . . "> etc.
So your choices are to either use a button (to perform the submit action on
the form) or to make an image of some sort and add "onclick=form.submit()"
or something similar to this.
The only way to call a post method is to perform the submit somehow, which
cannot be done from a hyperlink (since it does not have an onclick action
listener that I am aware of)
Additionally in some cases where I am not really worried about higher levels
of security or high amounts of data I write a doSomething() method and both
doGet() and doPost() only call doSomething().
Hope that helps somewhat
J
> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 19, 1999 7:58 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Calling servlet from hyper text link
>
>
> 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.
> >
>
> You need to use <form method="post"> to do this.
>
> >
> > Would appreciate any help.
> > Sanjay
> >
>
> Craig McClanahan
>
> ==============================================================
> =============
> 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