Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@ page import="java.sql.*" %>
- <%@page import ="java.sql.Date" %>
- <%@page import = "java.text.*" %>
- <%@ page import="java.io.*" %>
- <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <script
- src="https://code.jquery.com/jquery-3.2.1.min.js"
- integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
- crossorigin="anonymous"></script>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <link rel="stylesheet" type="text/css" href="css/style.css">
- <title>Insert title here</title>
- </head>
- <body>
- <ul>
- <li><a class="active" href="home.html">Home</a></li>
- <li><a class="active" href="roomsearch.html">Reserve a Room</a></li>
- </ul>
- <sql:setDataSource
- var="DS"
- driver="com.mysql.jdbc.Driver"
- url="jdbc:mysql://localhost:3306/hotel"
- user="root" password="Thunder0!"
- />
- <%
- String checkIn = request.getParameter("check-in");
- SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
- java.util.Date dt = sdf.parse(checkIn);
- java.sql.Date sqlD = new Date(dt.getTime());
- pageContext.setAttribute("in_date", sqlD);
- out.println("after sql " + sqlD + "<br>"); %>
- <%
- String checkOut = request.getParameter("check-out");
- SimpleDateFormat sdff = new SimpleDateFormat("MM/dd/yyyy");
- java.util.Date dtt = sdff.parse(checkOut);
- java.sql.Date sqlDD = new Date(dtt.getTime());
- pageContext.setAttribute("out_date", sqlDD);
- out.println("after sql " + sqlDD + "<br>");
- %>
- <% String state = request.getParameter("State");
- pageContext.setAttribute("ST", state);%>
- <c:set var = "st" value = "${ST}"/>
- <c:set var = "in" value = "${in_date}"/>
- <c:set var = "out" value = "${out_date}"/>
- <c:if test = "${st.equals('No state') }">
- <sql:query var="list_rooms" dataSource="${DS}">
- Select distinct R.hotelID, R.Room_no, H.city, H.country, R.sDate, R.EDate, R.Discount
- from Room R, Hotels H
- Where H.hotelID = R.hotelID
- and R.rType='<%= request.getParameter("room_type") %>'
- and H.country = '<%= request.getParameter("Country")%>'
- and not Exists
- (select S.hotelID, S.Room_no
- from Reservation S
- where
- ? BETWEEN S.InDate and S.OutDate
- and ? BETWEEN S.InDate and S.OutDate
- and
- R.HotelId = S.hotelID
- and R.Room_no = S.Room_no);
- <sql:param value = "${in}"/>
- <sql:param value = "${out}"/>
- </sql:query>
- </c:if>
- <c:if test = "${!st.equals('No state') }">
- <sql:query var="list_rooms" dataSource="${DS}">
- Select distinct R.hotelID, R.Room_no, H.city, H.country, R.sDate, R.EDate, R.Discount
- from Room R, Hotels H
- Where H.hotelID = R.hotelID
- and R.rType='<%= request.getParameter("room_type") %>'
- and H.state = '<%= request.getParameter("State")%>'
- and not Exists
- (select S.hotelID, S.Room_no
- from Reservation S
- where
- ? BETWEEN S.InDate and S.OutDate
- and ? BETWEEN S.InDate and S.OutDate
- and
- R.HotelId = S.hotelID
- and R.Room_no = S.Room_no);
- <sql:param value = "${in}"/>
- <sql:param value = "${out}"/>
- </sql:query>
- </c:if>
- <form name="form1" action="reserve.jsp" method="post">
- <input type="hidden" name="cids" value="<%=request.getParameter("cids")%>">
- <div align="center">
- <table>
- <caption><h2>Your info</h2></caption>
- <c:forEach var="room" items="${list_rooms.rows}">
- <tr>
- <td>${room.HotelID} </td>
- <td>${room.Room_no} </td>
- <td>${room.state} </td>
- <td>${room.city} </td>
- <td> <input name = "${room.Room_no},${room.hotelID}" type="checkbox" value = false; ></td>
- </tr>
- </c:forEach>
- </table>
- </div>
- <div align="center">
- <input type="submit" value="reserve" >
- </div>
- </form>
- </body>
- <script type="text/javascript">
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement