<%@page import="Dao.MemberDao"%>
<%@page import="Dto.PdsDto"%>
<%@page import="Dto.QADto"%>
<%@page import="java.util.*"%>
<%@page import="Dao.QADao"%>
<%@page import="Dto.MemberDto"%>
<%
String findword = request.getParameter("findword");
%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- 글쓰기 버튼 -->
<link
href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:700'
rel='stylesheet' type='text/css'>
<!-- bootstrapk table 링크 -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<!-- 검색창 밑 backgraund_img.css -->
<link href="<%=request.getContextPath()%>/CSS/QAList.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>자료실</title>
</head>
<body>
<jsp:include page="Header.jsp"></jsp:include>
<!-- mamber Session -->
<% List<PdsDto> pdslist = (List<PdsDto>)request.getAttribute("pdslist");
System.out.println("listsize: " + pdslist.size());
String search = request.getParameter("mode");
String searchstr = request.getParameter("str");
String optionstr = request.getParameter("option");
int option = 0;
if(optionstr != null){
option = Integer.parseInt(optionstr);
}
String totalstr = (String)request.getAttribute("total");
int total = 0;
if(totalstr != null){
total = Integer.parseInt(totalstr);
}
String currstr = (String)request.getAttribute("currpage");
int curr = 0;
if(currstr != null){
curr = Integer.parseInt(currstr);
}
int pagenums = 0;
if(total%10 == 0){
pagenums = total/10;
}else{
pagenums = total/10 +1;
}
System.out.println("" + total + " "+ curr + " " + pagenums);
int[] arr = new int[5];
//보통 앞에 두개 뒤에 두갠데
//그게 없을경우 앞에 하나더 ㄱ
boolean dotbefore = true;
boolean dotafter = true;
//페이지 전후로 점점이 있냐 없냐
if(pagenums <= 5){
dotbefore = false;
dotafter = false;
for(int i =1; i <= pagenums;i++){
arr[i-1] = i;
}
}else if(curr - 1 <= 2 ){
for(int i = 0; i < 5; i++){
arr[i] = i+1;
}
dotbefore = false;
}else if(pagenums - curr <= 2){
int j = 4;
for(int i = 0; i < 5; i++){
arr[i] = pagenums - j;
j--;
}
dotafter= false;
}else{
int j = -2;
for(int i = 0; i < 5; i++){
arr[i] = curr + j;
j++;
}
}
for(int i = 0; i < 5; i++){
System.out.println(arr[i]);
}
// 12345 56789
MemberDao dao = MemberDao.getInstance();
HttpSession memberSession = request.getSession(false);
MemberDto member = null;
if(memberSession!=null){
member = (MemberDto)memberSession.getAttribute("kh_member");
}
/* boolean c_login = false;
if(member != null){
c_login = true;
} */
boolean idcheck = true;
if (member == null) {
idcheck = false;
}
%>
<!-- 최상단 이미지 부분 -->
<div class="img">
<div class="content">
<!-- 검색 -->
<div class="inner_MAIN">
<div class="search_form">
<fieldset>
<div class="botton_main">
<!-- butt -->
<div class="inner_SUB">
<select class="search_Group" id="option" name="searchbox">
<option value="0">전체보기</option>
<option value="1">작성자</option>
<option value="2">제목</option>
</select> <input type="text" class="text_1" id="search" name="search"
maxlength="20" style="margin: -27px;">
<div class="button-row">
<div>
<a id="searchQA" name="searchQA" onclick="srch()"
title="검색"> </a>
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<!-- img_위에 망 덮어씌움 이유 : 이미지가 색이 강력크 .. ㅋㅌ 방지용 -->
<div class="img-cover"></div>
</div>
<div style="width: 1020px; margin: 50px auto 30px; text-align: center;">
<h2 style="font-size: 1.5em; font-weight: 680;">자료실</h2>
</div>
<!-- 게시판 table -->
<div style="min-height: 220px" align="center">
<table style="width: 1100px;" class="table">
<col width="100">
<col width="200">
<col width="300">
<col width="100">
<col width="150">
<thead>
<tr>
<th scope="col">번호</th>
<th scope="col">작성자</th>
<th scope="col">제목</th>
<th scope="col">조회수</th>
<th scope="col">날자</th>
</tr>
</thead>
<% /* List 사이즈 정의 */
if (pdslist == null || pdslist.size() == 0) {
%>
<tr>
<td colspan="3">작성된 글이 없습니다</td>
</tr>
<%
} else {
int Articlenumber = 0; //글번호(삭제,글 나타나기 선언 객체)
/* List 뿌려주기 */
for (int i = 0; i < pdslist.size(); i++) {
PdsDto pds = pdslist.get(i);
%>
<tr>
<td><%=pds.getDel()%></td>
<td><%=pds.getId()%></td>
<td>
<a style="text-decoration: none;" href="<%=request.getContextPath() %>/JSP/Pdsdetail.jsp?seq=<%=pds.getSeq()%>"> <%=pds.getTitle()%>
</a></td>
<td><%=pds.getReadcount()%></td>
<td><%=pds.getRegdate()%></td>
</tr>
<%
}
}
%>
</table>
</div>
<!-- 글쓰기 버튼 -->
<div align="center">
<div class="border_Button" onclick="QAwrite()">
<p style="text-decoration: none;">자료올리기</p>
</div>
</div>
<!-- Page페이징 글자 표기 view -->
<div style="text-align: center;">
<%
String link = "";
if(search != null){
link = request.getContextPath() + "/PdsController?command=search&str=" + searchstr +"&option=" + option + "&pagenumber=";
}else{
link = request.getContextPath() + "/PdsController?command=list&pagenumber=";
}
%>
<img id="pageimg" style="min-width: 40px" src="./img/Page_left-arrow_1.png" alt="이미지없음"
class="btn" onclick="location='<%=link%>1'">
<c:if test="<%=dotbefore%>">..</c:if>
<%
for(int i = 0; i < 5; i++){
if(arr[i] != 0){
if(curr == arr[i]){
%>
<button class="btns mainbut_page" style="borderStyle: inset; color: pink" disabled="disabled"><%=arr[i]%></button>
<%
}else{
%>
<button class="btns mainbut_page" onclick="location='<%=link%><%=arr[i]%>'"><%=arr[i]%></button>
<%
}
}
}
%>
<c:if test="<%=dotafter%>">..</c:if>
<img id="pageimg" style="min-width: 40px" src="./img/Page_Right-arrow_1.png" alt="이미지없음"
class="btn" onclick="location='<%=link%><%=pagenums%>'">
</div>
<br>
<!-- 검색 -->
<script type="text/javascript">
<!-- 검색 -->
function srch(){
var search = document.getElementById("search");
var option = document.getElementById("option");
var str = "<%=request.getContextPath() %>/PdsController?command=search&str=" + search.value + "&option="+option.value;
location = str;
}
//자료올리기(완료)
function QAwrite() {
var idcheck = <%=idcheck%>; // 아이디값 불러옴
if (idcheck){
location = "<%=request.getContextPath() %>/JSP/Pdswrite.jsp";
}else{
alert('로그인을 해주세요.');
return;
}
}
</script>
<!-- Footer -->
<jsp:include page="Footer.jsp"></jsp:include>
</body>
</html>
<%@page import="Dto.MemberDto"%>
<%@page import="Dto.PdsDto"%>
<%@page import="Dao.PdsDao"%>
<%@ 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">
<link href="<%=request.getContextPath()%>/CSS/Table.css" rel="stylesheet">
<title>Pdswrite</title>
</head>
<body>
<%
MemberDto dto = (MemberDto)session.getAttribute("kh_member");
%>
<jsp:include page="../JSP/Header.jsp"></jsp:include>
<!-- 최상단 이미지 부분 -->
<div class="img">
<!-- img_위에 망 덮어씌움 이유 : 이미지가 색이 강력크 .. ㅋㅌ 방지용 -->
<div class="img-cover"></div>
</div>
<div style="width: 1020px; margin: 50px auto 30px; text-align: center;">
<h2 style="font-size: 1.5em; font-weight: 680;"> Pdswrite </h2>
</div>
<div class="outer-container" align="center">
<form action="Pdsupload.jsp" method="post" enctype="multipart/form-data" >
<input type="hidden" name="command" value="write">
<div class="inner-container">
<table border="0" style="border-collapse: collapse">
<col width="100"><col width="920">
<tr>
<td>아이디</td>
<td>
<input type="text" class="input_data" name="id" value="<%=dto.getId() %>" readonly="readonly" style="padding-left: 2px; border: 0;">
</td>
</tr>
<tr>
<td>제목</td>
<td>
<input type="text" class="input_data" name="title" required >
</td>
</tr>
<tr>
<td>파일 업로드</td>
<td>
<input type="file" class="input_data" name="fileload" style="width: 400px" required>
</td>
</tr>
<tr style="border-bottom: 0;">
<td style="vertical-align: top; padding-top: 8px;">내용</td>
<td style="padding-top: 8px;">
<textarea class="input_data" name="content" style="width:90%; height: 500px; " placeholder="내용을 입력하세요."></textarea>
</td>
</tr>
</table>
</div>
<input class="mainbut" type="submit" value="올리기">
<button class="mainbut" type="button" onclick="location= '<%=request.getContextPath() %>/PdsController?command=list'">돌아가기</button>
</form>
</div>
<jsp:include page="../JSP/Footer.jsp"></jsp:include>
</body>
</html>
<%@page import="Dto.MemberDto"%>
<%@page import="Dto.PdsDto"%>
<%@page import="Dao.PdsDao"%>
<%@ 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">
<link href="<%=request.getContextPath()%>/CSS/Table.css" rel="stylesheet">
<title>Pdsdetail</title>
</head>
<body>
<%
MemberDto mdo =(MemberDto) session.getAttribute("kh_member");
boolean idcheck = false;
String idstr = "";
if(mdo != null){
idcheck = true;
idstr = mdo.getId();
}
String wk =request.getParameter("seq");
int pdsid=Integer.parseInt(wk);
PdsDao dao = PdsDao.getInstance();
dao.pdsReadCount(pdsid);
PdsDto dto =dao.getPDS(pdsid);
%>
<jsp:include page="../JSP/Header.jsp"></jsp:include>
<!-- 최상단 이미지 부분 -->
<div class="img">
<!-- img_위에 망 덮어씌움 이유 : 이미지가 색이 강력크 .. ㅋㅌ 방지용 -->
<div class="img-cover"></div>
</div>
<div style="width: 1020px; margin: 50px auto 30px; text-align: center;">
<h2 style="font-size: 1.5em; font-weight: 680;"> Pdsdetail </h2>
</div>
<div class="outer-container">
<form action="../PdsController?command=detailPds" method="post">
<div class="inner-container">
<table border="0" style="border-collapse: collapse;">
<col width="100">
<col width="920">
<tr>
<td>작성자</td>
<td style="text-align: left; padding-left: 10px;"><%=dto.getId() %></td>
</tr>
<tr>
<td>제목</td>
<td style="text-align: left; padding-left: 10px;"><%=dto.getTitle() %></td>
</tr>
<tr>
<td>작성일</td>
<td style="text-align: left; padding-left: 10px;"><%=dto.getRegdate() %></td>
</tr>
<tr>
<td>다운로드</td>
<td><input type="button" id="btndown" name="btndown" value="<%=dto.getFilename() %>" style="float: left; margin-left: 10px;"
onclick="filedown()"></td>
</tr>
<tr style="border-bottom: 0;">
<td style="vertical-align: top; padding-top: 8px;">내용</td>
<td><textarea class="input_data" name="content" style="width: 90%; height: 500px; outline: none" readonly="readonly"><%=dto.getContent() %></textarea></td>
</tr>
</table>
</div>
</form>
<form action="<%=request.getContextPath()%>/PdsController" method="post">
<input type="hidden" name="command" value="delete">
<input type="hidden" name="seq" value="<%=dto.getSeq()%>">
<input class="mainbut" id="delete" type="submit" value="삭제">
<button class="mainbut" id="update" type="button" onclick="location.href = '<%=request.getContextPath()%>/JSP/Pdsupdate.jsp?seq=<%=dto.getSeq()%>'" >수정하기</button>
</form>
</div>
<jsp:include page="../JSP/Footer.jsp"></jsp:include>
<script>
var del = document.getElementById("delete");
var up = document.getElementById("update");
var down = document.getElementById("btndown");
if(<%=!idcheck %> || '<%=idstr %>' !== '<%=dto.getId()%>'){
del.setAttribute("disabled", "disabled");
up.setAttribute("disabled", "disabled");
}
function filedown(){
if(<%=!idcheck %> || '<%=idstr %>' !== '<%=dto.getId()%>'){
alert("로그인하셔야 다운로드 가능합니다.");
}else{
location='<%=request.getContextPath() %>/PdsController?command=download&filename=<%=dto.getFilename()%>&seq=<%=dto.getSeq()%>'
}
}
</script>
</body>
</html>
<%@page import="Dto.PdsDto"%>
<%@page import="Dao.PdsDao"%>
<%@ 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>Pdsupdate</title>
<link href="<%=request.getContextPath()%>/CSS/Table.css" rel="stylesheet">
</head>
<body>
<%
String wk =request.getParameter("seq");
int pdsid=Integer.parseInt(wk);
PdsDao dao = PdsDao.getInstance();
PdsDto dto =dao.getPDS(pdsid);
%>
<jsp:include page="../JSP/Header.jsp"></jsp:include>
<!-- 최상단 이미지 부분 -->
<div class="img">
<!-- img_위에 망 덮어씌움 이유 : 이미지가 색이 강력크 .. ㅋㅌ 방지용 -->
<div class="img-cover"></div>
</div>
<div style="width: 1020px; margin: 50px auto 30px; text-align: center;">
<h2 style="font-size: 1.5em; font-weight: 680;"> Pdsupdate </h2>
</div>
<div class="outer-container" style="margin-bottom: 80px;">
<form action="<%=request.getContextPath() %>/PdsController" method="post">
<input type="hidden" name="seq" value="<%=pdsid %>">
<input type="hidden" name="command" value="update">
<div class="inner-container">
<table border="0" style="border-collapse: collapse;">
<col width="100">
<col width="920">
<tr>
<td>작성자</td>
<td><input type="text" class="input_data" name="id" value="<%=dto.getId() %>" style="border: 0;" readonly></td>
</tr>
<tr>
<td>작성일</td>
<td><input type="text" class="input_data" name="wdate" value="<%=dto.getRegdate() %>" style="border: 0;" readonly></td>
</tr>
<tr>
<td>제목</td>
<td><input type="text" class="input_data" name="title" value="<%=dto.getTitle() %>"></td>
</tr>
<tr style="border-bottom: 0;">
<td style="vertical-align: top; padding-top: 8px;">내용</td>
<td style="padding-top: 8px;"><textarea class="input_data" id="content" name="content"
style="width: 90%; height: 500px;" placeholder="내용을 입력하세요."><%=dto.getContent() %></textarea></td>
</tr>
</table>
</div>
<input class="mainbut" type="submit" value="수정하기">
</form>
</div>
<jsp:include page="../JSP/Footer.jsp"></jsp:include>
</body>
</html>
<%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@page import="org.apache.commons.fileupload.FileItem"%>
<%@page import="java.io.IOException"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="java.io.File"%>
<%@page import="Dto.PdsDto"%>
<%@page import="Dao.PdsDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String file = request.getParameter("fileload");
System.out.println("file:" + file);
%>
<!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>
<%!
public String processUploadFile(FileItem fileItem, String dir, JspWriter out) throws IOException {
String fileName = fileItem.getName();
long sizeInBytes = fileItem.getSize();
// 업로드한 파일이 정상일 경우
if(sizeInBytes > 0){
int idx = fileName.lastIndexOf("\\");
if(idx == -1){
idx = fileName.lastIndexOf("/");
}
fileName = fileName.substring(idx+1);
try{
File uploadedFile = new File(dir, fileName);
fileItem.write(uploadedFile);
}catch(Exception e){}
}
return fileName;
}
%>
<%
//System.out.println(request.getRealPath("/"));
//String fupload = request.getRealPath("/")+"upload\\";
//"C:\\Users\\SJ\\Desktop\\project\\.metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps\\KH_SecondPJ\\upload\\";
//request.getContextPath()+"/upload/";
String fupload = "C:\\tmp";
System.out.println("파일 업로드 : " + fupload);
String yourTempDirectory = fupload;
int yourMaxRequestSize = 100 * 1024 * 1024;
int yourMaxMemorySize = 100 * 1024;
String id = "";
String title = "";
String content = "";
String filename = "";
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if(isMultipart){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setSizeThreshold(yourMaxMemorySize);
factory.setRepository(new File(yourTempDirectory));
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(yourMaxRequestSize);
/////////////////////////////////////////////////////////////////
List<FileItem> items = upload.parseRequest(request);
Iterator<FileItem> it = items.iterator();
while(it.hasNext()){
FileItem item = it.next();
if(item.isFormField()){
if(item.getFieldName().equals("id")){
id = item.getString("utf-8");
}else if(item.getFieldName().equals("title")){
title = item.getString("utf-8");
}else if(item.getFieldName().equals("content")){
content = item.getString("utf-8");
}
}
else{
if(item.getFieldName().equals("fileload")){
filename = processUploadFile(item, fupload, out);
}
System.out.println("filename : " + filename);
}
}
/////////////////////////////////////////////////////////////////
}else{
System.out.println("Multipart가 아닙니다");
}
boolean isS = PdsDao.getInstance().writePds(new PdsDto(id, title, content, filename));
if(isS){
%>
<script type="text/javascript">
alert("파일 업로드 성공");
location.href = "../PdsController?command=list";
</script>
<%
}else{
%>
<script type="text/javascript">
alert("다시 업로드를 진행해 주십시오");
location.href = "<%=request.getContextPath()%>/JSP/PdsList.jsp";
</script>
<%
}
%>
</body>
</html>
'JavaScript mini Project > Project java code ' 카테고리의 다른 글
Q&A List (0) | 2018.09.26 |
---|---|
About (0) | 2018.09.26 |
상담신청 (0) | 2018.09.26 |
Gallery (0) | 2018.09.26 |
Myinfo() (0) | 2018.09.24 |