Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How do I?  RSS feed

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nasser Aboobaker
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1072
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
Thanks a lot to all of you.
Nasser
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!