rendered paste body<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import = "java.util.*"%>
<%@page import = "java.sql.*"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function count()
{
var count=0;
alert("testing checkbox events");
count = count+1;
if(count==4)
alert("You can only select 4 values");
}
</script>
<script type="text/javascript">
function checkSeat()
{
for(int i=0; i<20; i++)
{
var ss = document.form1.seats[i].checked;
document.write(ss);
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LoginLogic</title>
</head>
<body>
<%
String arr[] = new String[20];
//setting of type,source,destination in session
String type = (String) session.getAttribute("type");
String source = (String)session.getAttribute("source");
String destination = (String) session.getAttribute("destination");
//connection for code
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:xe";
out.println(type + source + destination);
Connection con =DriverManager.getConnection(url,"system","test1234");
String query = "select code from booking where type=? and source=? and destination=?";
PreparedStatement ps = con.prepareStatement(query);
ps.setString(1,type);
ps.setString(2,source);
ps.setString(3,destination);
ResultSet rs = ps.executeQuery();
//connection for seats status
if(rs.next())
{
out.println("inside");
int code = rs.getInt("code");
out.println(code);
query = "select seatno,status from seats where code=? order by seatno";
PreparedStatement ps1 = con.prepareStatement(query);
ps1.setInt(1,code);
ResultSet rs1 = ps1.executeQuery();
out.println("here");
while(rs1.next())
{
out.println("inside rs1.next()");
int seatno = rs1.getInt("seatno");
String status = rs1.getString("status");
out.println(seatno+status);
arr[seatno] = status;
}
session.setAttribute("cde",code);
}
con.close();
}
catch(Exception e)
{
System.out.println(e + "LoginLogic");
}
%>
<form name="form1" method="post" action="Confirm.jsp">
<table width="661" height="357" border="1">
<caption align="top">
Seats availability
</caption>
<%
int i=0;int j=0;
for(i=0; i<5; i++){%>
<tr>
<%for(j=0; j<4; j++){%>
<td width="156"><label>
<div align="center"><%=(i*4)+j%>
<input type="checkbox" name="seats" value="<%=(i*4)+j%>" <%=arr[i*4+j]%> />
</div>
</label></td>
<%}%>
</tr>
<%}%>
</table>
<label></label>
<input type="submit" value="DONE" >
</form>
</body>
</html>