This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 3775

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: 39535
    
  27
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 - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default action of <a href="link">
 
Similar Threads
what is the reason for overriding the doGet() or doPost() method
doPost and doGet
calling post method
How does the service() identifies which among doPost or doGet to be called
how call doPost()