<%@page import="javax.sql.*"%>
<%@page import="javax.naming.*"%>
<%@page import="java.sql.*"%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
 

<%
 String id = request.getParameter("id");
 String pass =request.getParameter("pass");
 
 Connection conn = null;
 PreparedStatement pstmt =null;
 ResultSet rs = null;
 
 try{
  Context init=new InitialContext(); 
  DataSource ds =(DataSource) init.lookup("java:comp/env/jdbc/OracleDB"); 
  conn = ds.getConnection();
  
  pstmt=conn.prepareStatement("select * from o_member where id=?"); 
  pstmt.setString(1,id);
  rs=pstmt.executeQuery();
  
  if(rs.next()){  
   if(pass.equals(rs.getString("password"))){ 
    session.setAttribute("id",id);
    out.println("<script>");
    out.println("location.href='main.jsp'"); 
    out.println("</script>");
   }
  }
  out.println("<script>");
  out.println("location.href='loginForm.jsp'"); 
  out.println("</script>");
 }catch(Exception e){
  e.printStackTrace();
 }
%>
</body>
</html>