Im populating customer data by iterating a customer list as following in the jsp.
Now in the action either edit or delete each record i want to track which customer needs to be edit/delete. So in servlet how can i access the customer object which is in var listItems. If its not possible do i need to have hidden input variables with values and access them using getParameter in servlet?
Yes, only form elements are submitted as part of a form.
Remember that once the response leaves the server that it's just an HTML page. So there's no way that a JSTL value (or any other server-side value) can be submitted with a form that only exists on the client.
Please read this article to understand how JSP operates.
Bear Bibeault wrote:Yes, only form elements are submitted as part of a form.
Yes but defining hidden input variable does not gives a solution for identify which customer detail like fname to either edit or delete that record. Because it will eventually have a list of hidden input variables with same name and different values.
Bear Bibeault wrote:How is the user choosing which of the displayed items is to be submitted?
Thank you for the answer. Its like a data grid where each customer records are displayed with edit/delete button next to it. So once the user click on delete for example that cutomer information should be delete. So for that need to send the fname for the servlet to process know. That's where i need to know how to track it.
fname? What's that? Is it the primary key for the database record?
In any case, you need to send the primary key for the record to identify which one was chosen.
This is not a JSP issue, it's an HTML issue. How would you construct the HTML, and perhaps JavaScript, of this page to be able to submit the primary key of the record?
Once you've answered that question, then what you need to do in the JSP becomes clear.
here you can send your primary key and variable(here it is mode) which tells servlet that edit is clicked or delete and you will be able to do coding according to that variable.