Java Quiz Player

Blog Post

JSP: Select and Process Table Row Data

May 14, 2014

Case 3: Using Submit Button to Select & Submit Single Row Data

1. Room Selection form:

image 3a

In the page the search result data is displayed in rows using JSTL tags with data from the session attribute availableRooms. Each row is displayed with a submit button as a column value. The submit button is enclosed within a HTML form reserveSubmitForm. All the table row (room) data that is to be submitted are set as hidden field values within the reserveSubmitForm.

The following is the code snippet to display the available rooms:

<c:forEach var="room" items="${sessionScope.availableRooms}" >
  <form name="reserveSubmitForm" action="reserve.jsp">
    <input type="submit" name="reserveButton" value="Reserve"</input>
    <input type="hidden" name="roomno" value="${}"</input>
    <input type="hidden" name="roomtype" value="${room.type}"</input>

The user selects a table row and submits the form by clicking the Reserve button. This action takes the user to the Reservation form. Note that one action does the selection and the submit.

Note that only one row can be processed on submitting the form, i.e., only one room can be reserved by the clerk at a time.

2. Reservation form:

The selected row data is available in this form as request parameter values of hidden fields in the reserveSubmitForm of Selection form.

The following is the code snippet to show the selected row data:

image 3b

Details to complete the reservation process are entered (guest and payment info, reservation dates etc.,) and the form is submitted for the reservation confirmation.

The Confirmation form shows the hotel room reservation confirmation details (this form's screenshot is not shown in this post).

<< Back to Case 2 | << Back to the post

Return to top


Comments are welcome. Please note that comments are moderated.
Email to: info(at)javaquizplayer(dot)com.