<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" a href="css/sample1.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" a href="css/show.css">
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<header>
영화관 DATABASE ver 1.01
</header>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.jsp">HOME</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">영화관리<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="input.jsp">입력</a></li>
<li><a href="out.do">출력</a></li>
<li><a href="modify1.jsp">수정</a></li>
<li><a href="delete1.jsp">삭제</a></li>
<li><a href="search.jsp">검색</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">로그인관리 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="member.jsp">회원가입</a></li>
<li><a href="login.jsp">로그인</a></li>
<li><a href="logout.do">로그아웃</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<c:choose>
<c:when test="${login == true && member != null}">
<li>
<a href="logout.do"><span class="glyphicon glyphicon-log-in"></span> 환영합니다!! ${member.id}님</a>
<a href="logout.do"><span class="glyphicon glyphicon-log-in"></span> 로그아웃</a>
</li>
</c:when>
<c:otherwise>
<li><a href="member.jsp"><span class="glyphicon glyphicon-user"></span>회원가입</a></li>
<li><a href="login.jsp"><span class="glyphicon glyphicon-log-in"></span> 로그인</a></li>
</c:otherwise>
</c:choose>
</ul>
</div>
</div>
</nav>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">영화정보입력</h3>
<form action="input.do" method="post" enctype="multipart/form-data">
<table border="1" align="center">
<tr>
<th>영화제목</th>
<td><input type="text" name="movie"></td>
</tr>
<tr>
<th>주인공</th>
<td><input type="text" name="lead"></td>
</tr>
<tr>
<th>감독</th>
<td><input type="text" name="director"></td>
</tr>
<tr>
<th>내용</th>
<td><textarea rows="10" cols="30" name="story"></textarea>
</tr>
<tr>
<th>가격</th>
<td><input type="text" name="price"></td>
</tr>
<tr>
<th>포스터</th>
<td><input type="file" name="poster"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="전송">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<c:choose>
<c:when test="${login == true && member != null}">
<h3 align="center">영화출력</h3>
<table border="1" align="center" width="1200px">
<tr>
<th>영화제목</th><th>주인공</th><th>감독</th>
<th>가격</th><th>포스터</th>
</tr>
<c:forEach items="${list}" var="dto">
<tr>
<td>${dto.movie}</td><td>${dto.lead}</td>
<td>${dto.director}</td>
<td>${dto.price}</td>
<td><a href="out2.jsp?movie=${dto.movie}"><img src="image/${dto.poster}" width="60px" height="90px"></a></td>
</tr>
</c:forEach>
</table>
</c:when>
<c:otherwise>
<script type="text/javascript">
window.onload=function() {
alert("로그인 후에 사용해주세요!")
}
</script>
</c:otherwise>
</c:choose>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<%@ include file="dbcon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<%!
String pmovie;
String movie,story,poster;
%>
<%
request.setCharacterEncoding("utf-8");
pmovie = request.getParameter("movie");
String sql = "select movie,story,poster from db02161 where movie=?";
psmt = con.prepareStatement(sql);
psmt.setString(1, pmovie);
rs = psmt.executeQuery();
if(rs.next()) {
movie = rs.getString(1);
story = rs.getString(2);
poster = rs.getString(3);
}
%>
<table border="1" align="center" width="1200px">
<tr>
<th>영화제목</th><th>내용</th><th>포스터</th>
</tr>
<tr>
<td><%=movie%></td><td><%=story%></td>
<td>
<img src ="image/<%=poster%>" width="400px" height="600px">
</td>
</tr>
</table>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">수정할 영화 검색</h3>
<form action="modify2.jsp">
<table border="1" align="center">
<tr>
<th>영화제목</th>
<td><input type="text" name="movie"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="전송">
<input type="reset" value="취소">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<%@ include file="dbcon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<%!
String mname;
String movie,lead,director,story;
int price;
String poster;
%>
<%
request.setCharacterEncoding("utf-8");
mname = request.getParameter("movie");
String sql ="select * from db02161 where movie=?";
psmt = con.prepareStatement(sql);
psmt.setString(1, mname);
rs = psmt.executeQuery();
if(rs.next()) {
movie = rs.getString(1);
lead = rs.getString(2);
director = rs.getString(3);
story = rs.getString(4);
price = rs.getInt(5);
poster = rs.getString(6);
}
%>
<h3 align="center">영화데이터 삭제</h3>
<form action="modify.do" method="post" enctype="multipart/form-data">
<table border="1" align="center">
<tr>
<th>영화제목</th>
<td><input type="text" name="movie" value="<%=movie%>" readonly></td>
</tr>
<tr>
<th>주인공</th>
<td><input type="text" name="lead" value="<%=lead%>"></td>
</tr>
<tr>
<th>감독</th>
<td><input type="text" name="director" value="<%=director%>"></td>
</tr>
<tr>
<th>내용</th>
<td><textarea rows="10" cols="30" name="story"><%=story%></textarea>
</tr>
<tr>
<th>가격</th>
<td><input type="text" name="price" value="<%=price%>"></td>
</tr>
<tr>
<th>포스터</th>
<td>
<input type="file" name="poster">
<img src="image/<%=poster%>" width="40px" height="60px">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="수정">
<input type="reset" value="리셋">
</td>
</tr>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<c:choose>
<c:when test="${login == true && member != null}">
<h3 align="center">삭제할 영화 검색</h3>
<form action="delete2.jsp">
<table border="1" align="center">
<tr>
<th>영화제목</th>
<td><input type="text" name="movie"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="전송">
<input type="reset" value="취소">
</td>
</tr>
</table>
</form>
</c:when>
<c:otherwise>
<script type="text/javascript">
window.onload=function() {
alert("로그인 후에 사용해주세요!")
}
</script>
</c:otherwise>
</c:choose>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<%@ include file="dbcon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<%!
String dname;
String movie,lead,director,story;
int price;
String poster;
%>
<%
request.setCharacterEncoding("utf-8");
dname = request.getParameter("movie");
String sql ="select * from db02161 where movie=?";
psmt = con.prepareStatement(sql);
psmt.setString(1, dname);
rs = psmt.executeQuery();
if(rs.next()) {
movie = rs.getString(1);
lead = rs.getString(2);
director = rs.getString(3);
story = rs.getString(4);
price = rs.getInt(5);
poster = rs.getString(6);
}
%>
<h3 align="center">영화데이터 삭제</h3>
<form action="delete.do" method="post" enctype="multipart/form-data">
<table border="1" align="center">
<tr>
<th>영화제목</th>
<td><input type="text" name="movie" value="<%=movie%>" readonly></td>
</tr>
<tr>
<th>주인공</th>
<td><input type="text" name="lead" value="<%=lead%>" readonly></td>
</tr>
<tr>
<th>감독</th>
<td><input type="text" name="director" value="<%=director%>" readonly></td>
</tr>
<tr>
<th>내용</th>
<td><textarea rows="10" cols="30" name="story" readonly><%=story%></textarea>
</tr>
<tr>
<th>가격</th>
<td><input type="text" name="price" value="<%=price%>" readonly></td>
</tr>
<tr>
<th>포스터</th>
<td>
<input type="file" name="poster" value="<%=poster%>" readonly>
<img src="image/<%=poster%>" width="40px" height="60px">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="삭제">
<input type="reset" value="리셋">
</td>
</tr>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">영화 검색</h3>
<form action="search.do" method="get">
<table border="1" align="center">
<tr>
<th>검색항목</th>
<td>
<select name="item">
<option value="movie">영화제목</option>
<option value="lead">주인공</option>
<option value="director">감독</option>
<option value="story">스토리</option>
</select>
</td>
</tr>
<tr>
<th>입력</th>
<td><input type="text" name="value"> </td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="검색">
<input type="reset" value="취소">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"></jsp:include>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">검색한 영화 출력</h3>
<table border="1" align="center" width="1200px">
<tr>
<th>영화제목</th><th>주인공</th><th>감독</th>
<th>내용</th><th>가격</th><th>포스터</th>
</tr>
<c:forEach items="${lista}" var="dto">
<tr>
<td>${dto.movie}</td><td>${dto.lead}</td><td>${dto.director}</td>
<td>${dto.story}</td><td>${dto.price}</td>
<td><img src="image/${dto.poster}" width="60px" height="90px"></td>
</tr>
</c:forEach>
</table>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">회원가입</h3>
<form action="member.do" method="get">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td><input type="text" name="id"> </td>
</tr>
<tr>
<th>패스워드</th>
<td><input type="password" name="pw"> </td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="가입">
<input type="reset" value="취소">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"></jsp:include>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">회원가입</h3>
<form action="login.do" method="get">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td><input type="text" name="id"> </td>
</tr>
<tr>
<th>패스워드</th>
<td><input type="password" name="pw"> </td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="로그인">
<input type="reset" value="취소">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"></jsp:include>
</html>
html부분
java부분
package com.ezen;
public class DTO {
String movie,lead,director,story;
int price;
String poster;
public DTO() {
}
public DTO(String movie, String lead, String director, String story, int price, String poster) {
super();
this.movie = movie;
this.lead = lead;
this.director = director;
this.story = story;
this.price = price;
this.poster = poster;
}
public String getMovie() {
return movie;
}
public void setMovie(String movie) {
this.movie = movie;
}
public String getLead() {
return lead;
}
public void setLead(String lead) {
this.lead = lead;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getStory() {
return story;
}
public void setStory(String story) {
this.story = story;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getPoster() {
return poster;
}
public void setPoster(String poster) {
this.poster = poster;
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Input implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
DAO dao;
try {
dao = new DAO();
dao.insert(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Out implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
ArrayList<DTO> list = dao.out();
request.setAttribute("list", list);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Modify implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
dao.modify(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Delete implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
dao.delete(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Search implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
ArrayList<DTO> list = dao.search(request);
request.setAttribute("lista", list);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
public class MemberDTO {
String id,pw;
public MemberDTO() {
}
public MemberDTO(String id, String pw) {
super();
this.id = id;
this.pw = pw;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPw() {
return pw;
}
public void setPw(String pw) {
this.pw = pw;
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Member implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
dao.member(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class Login implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
MemberDTO member = dao.login(request);
if(member !=null) {
HttpSession hs = request.getSession();
hs.setAttribute("member", member);
hs.setAttribute("login", true);
request.setAttribute("vpage", "index.jsp");
}
else {
request.setAttribute("vpage", "login.jsp");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Logout implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
DAO dao = new DAO();
dao.logout(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("*.do")
public class FrontController extends HttpServlet {
private static final long serialVersionUID = 1L;
public FrontController() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uri = request.getRequestURI();
String path = request.getContextPath();
String fname = uri.substring(path.length());
service service = null;
String vpage = null;
if(fname.equals("/input.do")) {
service = new Input();
service.aaa(request, response);
vpage="index.jsp";
}
if(fname.equals("/out.do")) {
service = new Out();
service.aaa(request, response);
vpage="out.jsp";
}
if(fname.equals("/modify.do")) {
service = new Modify();
service.aaa(request, response);
vpage="index.jsp";
}
if(fname.equals("/delete.do")) {
service = new Delete();
service.aaa(request, response);
vpage="index.jsp";
}
if(fname.equals("/search.do")) {
service = new Search();
service.aaa(request, response);
vpage="searchout.jsp";
}
if(fname.equals("/member.do")) {
service = new Member();
service.aaa(request, response);
vpage="index.jsp";
}
if(fname.equals("/login.do")) {
service = new Login();
service.aaa(request, response);
vpage=(String)request.getAttribute("vpage");
}
if(fname.equals("/logout.do")) {
service = new Logout();
service.aaa(request, response);
vpage="index.jsp";
}
RequestDispatcher rd = request.getRequestDispatcher(vpage);
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
package com.ezen;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.oreilly.servlet.MultipartRequest;
public class DAO {
Connection con;
PreparedStatement psmt;
ResultSet rs,rs1,rs2;
String driver="oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:xe";
ArrayList<DTO> list = new ArrayList<DTO>();
public DAO() throws ClassNotFoundException {
Class.forName(driver);
try {
con=DriverManager.getConnection(url, "ezen", "12345");
} catch (SQLException e) {
e.printStackTrace();
}
}
public void insert(HttpServletRequest request) {
String sd = "C://12월국비//JSP//day24_//src//main//webapp//image";
int filesize = 1024*1024*10;
String encType="UTF-8";
try {
MultipartRequest multi = new MultipartRequest(
request,sd,filesize,encType);
String movie = multi.getParameter("movie");
String lead = multi.getParameter("lead");
String director = multi.getParameter("director");
String story = multi.getParameter("story");
int price = Integer.parseInt(multi.getParameter("price"));
String poster = multi.getFilesystemName("poster");
String sql = "insert into db02161 values (?,?,?,?,?,?)";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, movie);
psmt.setString(2, lead);
psmt.setString(3, director);
psmt.setString(4, story);
psmt.setInt(5, price);
psmt.setString(6, poster);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public ArrayList<DTO> out() {
String sql = "select * from db02161";
try {
psmt = con.prepareStatement(sql);
rs = psmt.executeQuery();
while(rs.next()) {
String movie = rs.getString(1);
String lead = rs.getString(2);
String director = rs.getString(3);
String story = rs.getString(4);
int price = rs.getInt(5);
String poster = rs.getString(6);
DTO dto = new DTO();
dto.setMovie(movie);
dto.setLead(lead);
dto.setDirector(director);
dto.setStory(story);
dto.setPrice(price);
dto.setPoster(poster);
list.add(dto);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
public void modify(HttpServletRequest request) {
String sd = "C://12월국비//JSP//day24_//src//main//webapp//image";
int filesize = 1024*1024*10;
String encType="UTF-8";
try {
MultipartRequest multi = new MultipartRequest(
request,sd,filesize,encType);
String movie = multi.getParameter("movie");
String lead = multi.getParameter("lead");
String director = multi.getParameter("director");
String story = multi.getParameter("story");
int price = Integer.parseInt(multi.getParameter("price"));
String poster = multi.getFilesystemName("poster");
String sql = "update db02161 set lead=?,director=?,story=?,"
+ "price=?,poster=? where movie=?";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, lead);
psmt.setString(2, director);
psmt.setString(3, story);
psmt.setInt(4, price);
psmt.setString(5, poster);
psmt.setString(6, movie);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void delete(HttpServletRequest request) {
String sd = "C://12월국비//JSP//day24_//src//main//webapp//image";
int filesize = 1024*1024*10;
String encType="UTF-8";
MultipartRequest multi;
try {
multi = new MultipartRequest(
request,sd,filesize,encType);
String dname = multi.getParameter("movie");
String sql = "delete from db02161 where movie=?";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, dname);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public ArrayList<DTO> search(HttpServletRequest request) {
String item = request.getParameter("item");
String value = request.getParameter("value");
String sql = "select * from db02161 where "+item+" like ?";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, '%'+value+'%');
rs = psmt.executeQuery();
while(rs.next()) {
String movie = rs.getString(1);
String lead = rs.getString(2);
String director = rs.getString(3);
String story = rs.getString(4);
int price = rs.getInt(5);
String poster = rs.getString(6);
DTO dto = new DTO();
dto.setMovie(movie);
dto.setLead(lead);
dto.setDirector(director);
dto.setStory(story);
dto.setPrice(price);
dto.setPoster(poster);
list.add(dto);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
public void member(HttpServletRequest request) {
try {
request.setCharacterEncoding("utf-8");
String id = request.getParameter("id");
String pw = request.getParameter("pw");
String sql = "insert into db02162 values (?,?)";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, id);
psmt.setString(2, pw);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
public MemberDTO login(HttpServletRequest request) {
String id = request.getParameter("id");
String pw = request.getParameter("pw");
String sql = "select * from db02162 where id=? and pw=?";
MemberDTO member = null;
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, id);
psmt.setString(2, pw);
rs = psmt.executeQuery();
if(rs.next()) {
member = new MemberDTO();
member.setId(id);
member.setPw(pw);
}
else {
member = new MemberDTO();
member = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
return member;
}
public void logout(HttpServletRequest request) {
HttpSession hs = request.getSession();
hs.removeAttribute("member");
hs.removeAttribute("login");
hs.setAttribute("login", false);
}
}
'JSP' 카테고리의 다른 글
230217_서블릿 (0) | 2023.02.17 |
---|---|
230215_서블릿 (0) | 2023.02.15 |
230214_서블릿 (0) | 2023.02.14 |
230213_서블릿 (0) | 2023.02.13 |
230210_서블릿 (0) | 2023.02.10 |
댓글