<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
JSP Page</title>
</head>
<body>
<%
Connection connection = null;
String DBUrl="jdbc:derby://localhost:1527/CRM";
try
{
String Cid, strSQL, CNAME, CITY, STATE, EMAIL, mySTATE;
mySTATE=request.getParameter("STATE");
connection = DriverManager.getConnection(DBUrl);
Statement SQLStatement = connection.createStatement();
String stateCheckbox1 = request.getParameter("CA");
String stateCheckbox2 = request.getParameter("OR");
String stateCheckbox3 = request.getParameter("WA");
if (stateCheckbox1 != null)
{mySTATE="CA";}
else if (stateCheckbox2 != null)
{mySTATE="OR";}
else
{mySTATE="WA";}
strSQL="select * from CUSTOMER where STATE='" +mySTATE+ "CA";
ResultSet rs = SQLStatement.executeQuery(strSQL);
out.println("<table border='1' width='400' cellspacing=1>");
out.println(" <thead><tr>");
out.println("<th>CID</th> <th>CNAME</th> <th>CITY</th> <th>Rating</th>");
out.println("</tr></thead>");
while (rs.next())
{
Cid=rs.getString("CID");
CNAME=rs.getString("CNAME");
CITY=rs.getString("CITY");
STATE=rs.getString("STATE");
EMAIL=rs.getString("EMAIL");
out.println("<tr>");
out.println("<td width='25%'>" + Cid + "</td>");
out.println("<td width='25%'>" + CNAME + "</td>");
out.println("<td width='25%'>" + CITY + "</td>");
out.println("<td width='25%'>" + STATE + "</td>");
out.println("<td width='25%'>" + EMAIL + "</td>");
out.println("</tr>");
}
rs.close();
}
catch(SQLException e)
{
out.println(e.getMessage());
}
out.println("</table>");
%>
</body>
</html>