aspose file tools*
The moose likes JSP and the fly likes How do I? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How do I?" Watch "How do I?" New topic
Author

How do I?

Nasser Aboobaker
Ranch Hand

Joined: Dec 06, 2000
Posts: 104
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: 3892
    
    5
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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Nasser Aboobaker
Ranch Hand

Joined: Dec 06, 2000
Posts: 104
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
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
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
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: 3892
    
    5
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
Nasser Aboobaker
Ranch Hand

Joined: Dec 06, 2000
Posts: 104
Hi friends,
Thanks a lot to all of you.
Nasser
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I?