capturing button click in jsp & passing information to servlet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abha_Salhotra
Posted On:   Thursday, April 15, 2004 04:48 AM


i am facing the following problem:

i have one jsp file jsp1.jsp. in this jsp, i am displaying certain list and at the bottom there are 3 buttons, with different functionality. now i want to capture which button is clicked, and pass this information to a servlet. depending upon the button clicked, i have to do processing in servlet.

i am able to capture the event in jsp by writing function in javascript, but am not able to pass this value to servlet.

any help please!!!!


Abha Salhotra

Re: capturing button click in jsp & passing information to servlet

Posted By:   Erik_Runia  
Posted On:   Thursday, April 15, 2004 09:57 AM

the name parameter of an html submit button should be your request parameter name in the servlet, and the "value" of your button (its label) should be the value of that request parameter.



session.getAttribute("nameOfButton") should return the label of the button, this is the easiest way to determine which button is pressed, as long as they all have unique labels.



By the way, it may be session.getParameter, I always forget which one is deprecated and which isnt.. DOH! ;-)

About | Sitemap | Contact