Hi, I have a servlet which forwards some values from database to another jSP page. Inside that jsp page one of the item which is is displayed as an link. How do I recognize on which item the user clicked( I mean on which row the user clicked userID) and how do I grab the value and pass it to another servlet?. I hope I have explained it clearly. Thanks in advance. Nasser
Kyle Brown
author
Ranch Hand
Joined: Aug 10, 2001
Posts: 3879
posted
0
A common trick is to include some sort of row and column id in the link inside each table element when you generate the link. Kyle
Hi Kyle, Thanks for your reply. But can you be litle elaborative. Ok I have used a rowid but when user clicked let us say on row num 15 and it has an empid of 001 then how do I grab this value and pass it to another servlet?. Do I have to use JavaScript, well to be frank, I am trying to avoid any client side programming (if possible). Or can I use the empid as parameter to the url and inside Servlet use Get method to get it and process it?. Thanks in advance. Nasser
ersin eser
Ranch Hand
Joined: Feb 22, 2001
Posts: 1072
posted
0
Well when you loop thru in your rs and put them out add something to a link like rowID=1& etc; so you know where that resides in your rs . Is it a good idea ? Quick solution but you gotta watch your cursor and have to set it to backward/forwards also gets ugly with deletes etc. But if all you want is a quick link then i guess this is a quick way to do it.
Manohar Karamballi
Ranch Hand
Joined: Jul 17, 2001
Posts: 227
posted
0
I am giving some HTML- JSP based solution and a minimal javascript... In HTML maintain a hidden field for EmployeeId.. On clicking each link call a javascript method with parameter as employee Id.. Set that Hidden field and do submit.. Note: Give url of a servlet to which action is to be directed as a action of ur form Tag.
Frances Teng
Greenhorn
Joined: Oct 29, 2001
Posts: 9
posted
0
Nasser: Let me make sure I understand your question: for every item you have a link, these links are created dynamicly. You have the information about the specific item when you create the links, am I right? you can pass the info in your link as parameters such as ...?parm1=a&parm2=b. Your servlet can take the parms and decide which item you are dealing with. France Teng
Originally posted by Nasser Aboobaker: Hi, I have a servlet which forwards some values from database to another jSP page. Inside that jsp page one of the item which is is displayed as an link. How do I recognize on which item the user clicked( I mean on which row the user clicked userID) and how do I grab the value and pass it to another servlet?. I hope I have explained it clearly. Thanks in advance. Nasser
Kyle Brown
author
Ranch Hand
Joined: Aug 10, 2001
Posts: 3879
posted
0
Originally posted by Nasser Aboobaker: Hi Kyle, Thanks for your reply. But can you be litle elaborative. Ok I have used a rowid but when user clicked let us say on row num 15 and it has an empid of 001 then how do I grab this value and pass it to another servlet?. Do I have to use JavaScript, well to be frank, I am trying to avoid any client side programming (if possible). Or can I use the empid as parameter to the url and inside Servlet use Get method to get it and process it?. Thanks in advance. Nasser
Yes, follow ersin's advice below -- use both the rowID and the emPId as parameters to your servlet and then process them to find the right object. Kyle