Two Laptop Bag
The moose likes Servlets and the fly likes jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp" Watch "jsp" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Instead of calling different files for performing different
operations(based on the button click event) i want to
write a jsp page which should include all the operation to be performed .eg:add,delete,modify,view,listview.
to perform all the above mentioned operation in the same jsp
page,i want to know which button is clicked first.
so is there any option to check that in javascript and assign
the checked condition in some variable.
if this is acheived i think i can check it in jsp
and write coding accordingly in jsp.

thanks in advance,
kichu kichu
Ranch Hand

Joined: May 10, 2001
Posts: 59
can u make your question more clear???
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

If I understand your question correctly, you can use the fact that you know which button was pressed to determine the operation...
OK, that sounded confusing.
What I mean is, you can have several buttons on the page and the button pressed will be a part of the information returned to the server.
I'd have to go back and test, but if you give your buttons (or 'submit' or whatever) a name AND a value, it will be passed normally as a name/value.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
mohana konakanchi
Ranch Hand

Joined: May 16, 2001
Posts: 67
If I understand your problem correctly,
Your want to know, which button is pressed, so that you can do process that.
You add, Onclick = "someJavaScriptFunction();" to each button.
And use a global var btnCliked = "false";

in each javaScriptFunction() check the condition, if no other button is pressed, process the request. if some other button is pressed neglect the request.

function someJavaScriptFunction()
if(btnCliked == "false")
btnCliked = "true";
// do call related servelt
return false;
In Servelt
You need to check requested operation type, before processing.
Hope I answered your problem, if not please elabarate more.
Raja Shekhar
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
U wanted 2 manipulete/ do U.I.D operations
using single button instead of multilple button
if (rite)
A Liitle bit of Smart ness is needed 4 this...
just ..instially take one operation as defualt
and using java script decide on the next operation
pass that variable to the next JSP page
and depending on condition..
put the code...

Got IT

I agree. Here's the link:
subject: jsp
It's not a secret anymore!