Forums Register Login

get the value in a jsp page to the servlet

+Pie Number of slices to send: Send
//styleDetail.jsp



//ProductController.java



When i run the above code, a table is displayed with links. when i click on the link, the control is passed to the servlet 'ProductController' and i want to get the value of the link i have clicked.... If suppose the link clicked is 'ABC', this value should be read in the servlet..When i run the above code, the value of 'obj' is printed as 4 irrespective of any link i click in the jsp. Kindly help with a solution.....
+Pie Number of slices to send: Send
Do you really not indent your code? It's unreadable as is.
+Pie Number of slices to send: Send
Yes very bad indentation...

anyway, you have an iterator object that is assigned to your obj Object as in the code below, and in your servlet you will get the last value in the list assigned in the internal loop.



ofcourse you are writing something wrong here, because in the loop you will keep overwrite the value of the parameter "value" in the session scope and in the end get the last value. if you want to know which link has been clicked you should add an (id) as a parameter in the link for example like this:




By the way I see you are using <%= %> and <% %> tags. try to avoid them as much as possible, and use EL and JSTL instead such as ${obj.id}
+Pie Number of slices to send: Send


session is an one of the implicit object in jsp
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1540 times.
Similar Threads
get table values from jsp to servlet
Help in Debugging
Getting error
How to update a image using servlet?
how to read value of <a> tag in servlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:50:42.