This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Default action of <a href=" title="" /> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Default action of <a href="link">" Watch "Default action of <a href="link">" New topic
Author

Default action of <a href="link">

Vickey singh Verma
Greenhorn

Joined: Jul 11, 2008
Posts: 22
i was just trying out a program in which i created a link as
click here
//somelink here is a servlet
when the link is clicked i get a error that "The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL)."
i have put the code of the servlet in doPost() method. How can i make the link call the doPost().

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

i have put the code of the servlet in doPost() method. How can i make the link call the doPost().


Either you move that code to doGet() method by overriding it or override doGet() and call the doPost() within that so your request will be delegated to doPost().

For the latter,



SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Goutam Chowdhury
Ranch Hand

Joined: Jan 20, 2009
Posts: 44
I think you have to override doGet() (because its a link so everytime its doGet())instead of doPost...you can call doPost() from doGet() method


Goutam
SCJP 1.4


Thanks And Regards
Goutam Chowdhury (Scjp1.4 86%,SCWCD5 94%)
Vickey singh Verma
Greenhorn

Joined: Jul 11, 2008
Posts: 22
thank's for replying though i got u'r point but what my intention was to make the link call the doPost() method. I tried this
//<form name="AsIfIcare" method="post">
//<a href="somelink.do">clickhere</a>
//</form>

may be link always calls the doGet() by default.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41065
    
  43
may be link always calls the doGet() by default.

Not only "by default" - it will *always* be a GET; there's no way to make it use POST. It's similar to typing in a URL in the browser, or selecting a bookmark - those will always be GETs, too.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default action of <a href="link">
 
Similar Threads
how call doPost()
calling post method
How does the service() identifies which among doPost or doGet to be called
what is the reason for overriding the doGet() or doPost() method
doPost and doGet