Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default action of <a href="link">

 
Vickey singh Verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

 
Goutam Chowdhury
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vickey singh Verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic