Advertisement
Guest User

Untitled

a guest
May 7th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. @ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <%@ page import="java.sql.*" %>
  4. <%@page import ="java.sql.Date" %>
  5. <%@page import = "java.text.*" %>
  6. <%@ page import="java.io.*" %>
  7. <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  8. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
  9.  
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  11. <html>
  12. <head>
  13. <script
  14. src="https://code.jquery.com/jquery-3.2.1.min.js"
  15. integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  16. crossorigin="anonymous"></script>
  17. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  18. <link rel="stylesheet" type="text/css" href="css/style.css">
  19. <title>Insert title here</title>
  20. </head>
  21. <body>
  22. <ul>
  23. <li><a class="active" href="home.html">Home</a></li>
  24. <li><a class="active" href="roomsearch.html">Reserve a Room</a></li>
  25. </ul>
  26.  
  27.  
  28.  
  29. <sql:setDataSource
  30. var="DS"
  31. driver="com.mysql.jdbc.Driver"
  32. url="jdbc:mysql://localhost:3306/hotel"
  33. user="root" password="Thunder0!"
  34. />
  35. <%
  36. String checkIn = request.getParameter("check-in");
  37.  
  38.  
  39. SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
  40.  
  41. java.util.Date dt = sdf.parse(checkIn);
  42.  
  43. java.sql.Date sqlD = new Date(dt.getTime());
  44. pageContext.setAttribute("in_date", sqlD);
  45. out.println("after sql " + sqlD + "<br>"); %>
  46.  
  47. <%
  48. String checkOut = request.getParameter("check-out");
  49.  
  50.  
  51. SimpleDateFormat sdff = new SimpleDateFormat("MM/dd/yyyy");
  52.  
  53. java.util.Date dtt = sdff.parse(checkOut);
  54.  
  55. java.sql.Date sqlDD = new Date(dtt.getTime());
  56. pageContext.setAttribute("out_date", sqlDD);
  57. out.println("after sql " + sqlDD + "<br>");
  58. %>
  59.  
  60. <% String state = request.getParameter("State");
  61. pageContext.setAttribute("ST", state);%>
  62.  
  63.  
  64. <c:set var = "st" value = "${ST}"/>
  65.  
  66.  
  67. <c:set var = "in" value = "${in_date}"/>
  68. <c:set var = "out" value = "${out_date}"/>
  69.  
  70.  
  71. <c:if test = "${st.equals('No state') }">
  72. <sql:query var="list_rooms" dataSource="${DS}">
  73.  
  74. Select distinct R.hotelID, R.Room_no, H.city, H.country, R.sDate, R.EDate, R.Discount
  75. from Room R, Hotels H
  76. Where H.hotelID = R.hotelID
  77. and R.rType='<%= request.getParameter("room_type") %>'
  78. and H.country = '<%= request.getParameter("Country")%>'
  79. and not Exists
  80. (select S.hotelID, S.Room_no
  81. from Reservation S
  82. where
  83. ? BETWEEN S.InDate and S.OutDate
  84. and ? BETWEEN S.InDate and S.OutDate
  85. and
  86. R.HotelId = S.hotelID
  87. and R.Room_no = S.Room_no);
  88.  
  89. <sql:param value = "${in}"/>
  90. <sql:param value = "${out}"/>
  91. </sql:query>
  92. </c:if>
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. <c:if test = "${!st.equals('No state') }">
  102. <sql:query var="list_rooms" dataSource="${DS}">
  103.  
  104. Select distinct R.hotelID, R.Room_no, H.city, H.country, R.sDate, R.EDate, R.Discount
  105. from Room R, Hotels H
  106. Where H.hotelID = R.hotelID
  107. and R.rType='<%= request.getParameter("room_type") %>'
  108. and H.state = '<%= request.getParameter("State")%>'
  109. and not Exists
  110. (select S.hotelID, S.Room_no
  111. from Reservation S
  112. where
  113. ? BETWEEN S.InDate and S.OutDate
  114. and ? BETWEEN S.InDate and S.OutDate
  115. and
  116. R.HotelId = S.hotelID
  117. and R.Room_no = S.Room_no);
  118. <sql:param value = "${in}"/>
  119. <sql:param value = "${out}"/>
  120. </sql:query>
  121. </c:if>
  122.  
  123. <form name="form1" action="reserve.jsp" method="post">
  124. <input type="hidden" name="cids" value="<%=request.getParameter("cids")%>">
  125. <div align="center">
  126. <table>
  127.  
  128. <caption><h2>Your info</h2></caption>
  129.  
  130. <c:forEach var="room" items="${list_rooms.rows}">
  131. <tr>
  132. <td>${room.HotelID} </td>
  133. <td>${room.Room_no} </td>
  134. <td>${room.state} </td>
  135. <td>${room.city} </td>
  136. <td> <input name = "${room.Room_no},${room.hotelID}" type="checkbox" value = false; ></td>
  137.  
  138.  
  139. </tr>
  140.  
  141.  
  142.  
  143.  
  144. </c:forEach>
  145.  
  146.  
  147. </table>
  148. </div>
  149.  
  150. <div align="center">
  151. <input type="submit" value="reserve" >
  152. </div>
  153. </form>
  154.  
  155. </body>
  156.  
  157. <script type="text/javascript">
  158.  
  159.  
  160.  
  161. </script>
  162.  
  163.  
  164. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement