I have created a for loop to display all the value from database, a textfield and button.
So for each value displayed there will be one textfield and “reply” button.
So when i click on the “reply” button, the text in the textfield and together with the id of the value i am “replying” to will be store into database.
But how am i suppose to get the id of the specific value i am “replying” to?
Below is the code in the jsp page
<%
ConnectionDB uDB = new ConnectionDB();
Comment[] comment = uDB.getComment();
%>
<%
for (int i = 0; i < comment.length; i++) {
%>
<%=uDB.getMemberName(comment[i].getMemberId()).getFirstName()%>
<%=uDB.getMemberName(comment[i].getMemberId()).getLastName()%>
<%=comment[i].getCommentDesc() %>
<br><input type="text" name="replycommenttxt" size="20">
<input type="submit" name="replycommentbutton" value="reply" >
<% } %>
Store it in a hidden field of your form:
You should really learn about the JSP EL, the JSTL, and the MVC pattern. Reading data from a database in a JSP and using scriptlets is really bad practice.