Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling two servlets from different two Buttons In One Html Page

 
bujjib babu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am Having two buttons in my html page.

One is Add.
Second One is Delete.

When I press Add Button it should call AddServlet and when i press Delete button it should call DeleteServlet..

Please Justify me,..

Thanks..
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bujjib babu:
I am Having two buttons in my html page.

One is Add.
Second One is Delete.

When I press Add Button it should call AddServlet and when i press Delete button it should call DeleteServlet..

Please Justify me,..

Thanks..


Initially, you send your both the request to the same servlet (controller) then here you check what request it is, (one way is, give any value to button and then compare here...) and do whatever you want to do...



This is the simplest solution of your problem. I guess.

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could use Javascript to set the action of your form when you click one of the buttons.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call doAdd() of JavaScript on click of Add button.
In doAdd()
document.form.action = �path of AddServlet�
document.form.submit();

Call doDelete() of JavaScript on click of Delete button.
In doDelete()
document.form.action = �path of DeleteServlet�
document.form.submit();
 
bujjib babu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Reply..

Best Suggestion is JavaScript.. Its Working...

Bye
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best Suggestion is JavaScript.. Its Working...
...yes, until a client has JavaScript disabled, then either nothing will happen or your application will get confused. I try to avoid JavaScript whenever there is a more robust alternative (using plain (X)HTML/XML and server technologies), and always try to take as much responsibility away from the client as possible (especially due to cross-browser incompatibilities).

So if your application is to be used flexibly, I would suggest finding an alternative to JavaScript, or at least making provisions for if it is disabled.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic