Java Quiz Player

JSP: Select and Process Table Row Data

May 14, 2014

JSP Code for Case 1: Using Radio Button to Select the Row Data

roomSelection.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <%@ page isELIgnored="false" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <title>Some Hotel Resrvation System</title> </head> <body> <h2>Some Hotel Resrvation System - Selection form</h2> <p>The following rooms are available from the search. Select and submit
a row from the list to start the reservation process.</p> <form action="reserve.jsp"> <table border="1" cellpadding="5"> <tr> <th>Room No</th> <th>Room Type</th> <th>Smoking</th> <th>Rate</th> <th>Available Date</th> <th>Select</th> </tr> <c:forEach var="room" items="${sessionScope.availableRooms}"
varStatus="status"> <tr> <td>${room.no}</td> <td>${room.type}</td> <td>${room.smoking}</td> <td>${room.rate}</td> <td>${room.availableDate}</td> <td><input type="radio" name="radioButton"
value="${status.count}"></td> </tr> </c:forEach> </table> <input type="submit" name="reserveButton" value="Reserve"</input> <button type="button" name="backtosearchButton">Back to Search"</button> </form> </body> </html>

reserve.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <%@ page isELIgnored="false" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <title>Some Hotel Resrvation System</title> </head> <body> <h2>Some Hotel Resrvation System - Reservation form</h2> <p>The following room is selected for reservation. Enter guest details,
reservation dates, payment info and confirm.</p> <form> <c:set var="rowno" value="${param.radioButton - 1}"/> <h3>Room Details:</h3> <table border="1" cellpadding="5"> <tr> <td>Room No</td> <td>${sessionScope.availableRooms[rowno].no}</td> </tr> <tr> <td>Room Type</td> <td>${sessionScope.availableRooms[rowno].type}</td> </tr> <tr> <td>Smoking</td> <td>${sessionScope.availableRooms[rowno].smoking}</td> </tr> <tr> <td>Rate</td> <td>${sessionScope.availableRooms[rowno].rate}</td> </tr> <tr> <td>Available Date</td> <td>${sessionScope.availableRooms[rowno].availableDate}</td> </tr> </table> <p><h3>Guest Details, etc.,:</h3></p> ... <input type="submit" name="confirmButton" value="Confirm"</input> <button type="button" name="backtoselectButton">Back to Select"</button> <button type="button" name="backtosearchButton">Back to Search"</button> </form> </body> </html>

<< Back to the post

Return to top