package Controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import Dao.MemberDao;
import Dto.MemberDto;
public class MemberController extends HttpServlet{
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
public void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html; charset=utf-8");
MemberDao memberDao = MemberDao.getInstance();
String command = req.getParameter("command");
PrintWriter writer = resp.getWriter();
if(command.equals("login")) {
String id = req.getParameter("id");
String pw = req.getParameter("pw");
MemberDto member = memberDao.Login(id, pw);
if(member != null) {
HttpSession session = req.getSession(true);
session.setAttribute("kh_member", member);
session.setMaxInactiveInterval(30*60);
dispatch("JSP/About.jsp", req, resp);
}else {
req.setAttribute("login_false", true);
dispatch("JSP/Login.jsp", req, resp);
}
}else if(command.equals("logout")) {
HttpSession session = req.getSession(false);
if(session!=null) {
session.invalidate();
}
}else if(command.equals("regist_submit")) {
String id = req.getParameter("id");
String pw = req.getParameter("pw");
String name = req.getParameter("name");
String partner = req.getParameter("partner");
String phone = req.getParameter("phone");
String email = req.getParameter("email");
MemberDto member = new MemberDto(id,pw,name,partner,phone,email);
if(memberDao.addMember(member)) {
writer.write("<script>alert(\"성공적으로 회원가입 되었습니다.\"); location.href=\"JSP/Login.jsp\"; </script>");
writer.flush();
writer.close();
}else {
writer.write("<script>alert(\"회원가입에 실패했습니다.\"); location.href=\"JSP/Regi.jsp\"; </script>");
writer.flush();
writer.close();
}
}else if(command.equals("idCheck")){
String id = req.getParameter("id");
boolean b = memberDao.idCheck(id);
System.out.println(b);
StringBuffer msg = new StringBuffer();
msg.append("{");
msg.append(" \"status\" : \"success\", ");
msg.append(" \"duplicated\" : " + b);
msg.append(" } ");
writer.write(msg.toString());
writer.flush();
writer.close();
}else if(command.equals("updateInfo")) {
String id = req.getParameter("id");
String name = req.getParameter("name");
String partner = req.getParameter("partner");
String phone = req.getParameter("phone");
String email = req.getParameter("email");
MemberDto member = new MemberDto(id,name,partner,phone,email);
if(memberDao.update(member)) {
System.out.println("성공");
writer.println("<script>alert(\'정보가 변경되었습니다.\'); location=\'" + req.getContextPath()+ "/JSP/About.jsp\'</script>");
}else {
System.out.println("실패");
writer.println("<script>alert(\'정보 변경 실패.\'); location=\'" + req.getContextPath()+ "/JSP/About.jsp\'</script>");
}
}
}
public void dispatch(String urls, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
RequestDispatcher dispatch = req.getRequestDispatcher(urls);
dispatch.forward(req, resp);
}
}
package Controller;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.PdsDao;
import Dto.PdsDto;
public class PdsController extends HttpServlet {
private static final int BUFFER_SIZE = 8192;
private ServletConfig mConfig = null;
private int seq;
public void init(ServletConfig config) throws ServletException {
// TODO Auto-generated method stub
super.init(config);
mConfig = config;
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
public void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html; charset=utf-8");
String command = req.getParameter("command");
PdsDao pdao = PdsDao.getInstance();
if(command.equals("list")) {
int pagenum = 1;
String pagestr =req.getParameter("pagenumber");
if(pagestr != null) {
pagenum = Integer.parseInt(pagestr);
}
int totalcount = pdao.getAllCount(0, null);
System.out.println(totalcount);
int perpage = 10;
int startnum = 1;
if(pagenum != 1) {
startnum = (pagenum-1)*10 +1;
}
List<PdsDto> pdslist = pdao.getPdsList(startnum, startnum+9);
System.out.println(pdslist.size());
req.setAttribute("total", totalcount+"");
req.setAttribute("currpage", pagenum+"");
req.setAttribute("pdslist", pdslist);
dispatch("/JSP/PdsList.jsp", req, resp);
}
else if(command.equals("write")) {
String id = req.getParameter("id");
String title = req.getParameter("title");
String content = req.getParameter("content");
String filename = req.getParameter("filename");
System.out.println(id);
System.out.println(title);
System.out.println(content);
System.out.println(filename);
PdsDto pdto = new PdsDto(id, title, content, filename);
if(pdao.writePds(pdto)) {
dispatch("JSP/PdsList.jsp", req, resp);
}else {
dispatch("JSP/Pdswrite.jsp", req, resp);
}
}
else if(command.equals("detail")) {
String id = req.getParameter("id");
PdsDto pdto = new PdsDto();
boolean result = pdao.detailPds(pdto);
req.setAttribute("detail", pdto);
dispatch("Pdsdetail.jsp", req, resp);
}
else if(command.equals("update")) {
int seq = Integer.parseInt(req.getParameter("seq"));
String title = req.getParameter("title");
String content = req.getParameter("content");
boolean result = pdao.updatePds(seq, title, content);
if(result == true) {
System.out.println("수정되었습니다.");
}
else {
System.out.println("수정 실패.");
}
resp.sendRedirect("PdsController?command=list");
}
else if(command.equals("delete")){
int seq = Integer.parseInt(req.getParameter("seq"));
boolean result = pdao.deletePds(seq);
if(result == true) {
System.out.println("삭제되었습니다.");
}
else {
System.out.println("삭제 실패.");
}
resp.sendRedirect("PdsController?command=list");
}else if(command.equals("search")) {
PrintWriter writer = resp.getWriter();
String str = req.getParameter("str");
int option = Integer.parseInt(req.getParameter("option"));
List<PdsDto> pdslist = new ArrayList<>();
int pagenum = 1;
String pagestr =req.getParameter("pagenumber");
if(pagestr != null) {
pagenum = Integer.parseInt(pagestr);
}
if(option == 0) {
writer.println("<script> location = \'PdsController?command=list\'; </script>");
}else {
int totalcount = pdao.getAllCount(option, str);
System.out.println(totalcount);
int perpage = 10;
int startnum = 1;
if(pagenum != 1) {
startnum = (pagenum-1)*10 +1;
}
req.setAttribute("total", totalcount+"");
req.setAttribute("currpage", pagenum+"");
req.setAttribute("pdslist", pdslist);
pdslist = pdao.searchlist(option, str, startnum, startnum+9);
}
if(pdslist.isEmpty()) {
writer.println("<script>alert(\"찾으시는 내용이 없습니다.\"); location = \'PdsController?command=list\'; </script>");
}else {
req.setAttribute("pdslist", pdslist);
dispatch("/JSP/PdsList.jsp?mode=search&str="+str+"&option="+option, req, resp);
}
}else if(command.equals("download")) {
// String filename = new String(req.getParameter("filename").getBytes("8859_1"), "KSC5601");
String filename = req.getParameter("filename");
System.out.println("filename = " + filename);
System.out.println("seq =" + req.getParameter("seq"));
// download 회수를 증가
String pdsseq = req.getParameter("seq");
int seq = Integer.parseInt(pdsseq);
PdsDao dao = PdsDao.getInstance();
boolean isS = dao.downloadcount(seq);
/*if(!isS) {
}*/
BufferedOutputStream out = new BufferedOutputStream(resp.getOutputStream());
String filePath = "";
if(pdsseq != null) {
// tomcat
//filePath = mConfig.getServletContext().getRealPath("/upload");
// 개인폴더
filePath = "C:\\tmp";
}
try {
filePath = filePath + "\\" + filename;
File f = new File(filePath);
System.out.println("filePath:" + filePath);
if(f.exists() && f.canRead()) {
// 다운 로드 window 설정(다운로드창)
resp.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\";");
resp.setHeader("Content-Transfer-Encoding", "binary;");
resp.setHeader("Content-Length", "" + f.length());
resp.setHeader("Pragma", "no-cache;");
resp.setHeader("Expires", "-1;");
// 파일 생성, 기입
BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(f));
byte buffer[] = new byte[BUFFER_SIZE];
int read = 0;
while((read = fileInput.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
fileInput.close();
out.flush();
}else {
System.out.println("파일이 존재하지 않습니다");
}
}catch (Exception e) {
}finally {
if(out != null) {
out.flush();
out.close();
}
}
}
/*PrintWriter out = resp.getWriter();
out.println("<script> location= \'./JSP/Pdsdetail.jsp?seq="+seq+"\';</script>");*/
/*resp.sendRedirect("./JSP/Pdsdetail.jsp?seq="+seq); */
}
public void dispatch(String urls, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
RequestDispatcher dispatch = req.getRequestDispatcher(urls);
dispatch.forward(req, resp);
}
}
package Controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.QADao;
import Dto.QADto;
import Dto.ReplyDto;
public class QAController extends HttpServlet {
private static final long serialVersionUID = 1L;
// 공개
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
// 비밀
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doProcess(req, resp);
}
// Get, Post 구분안하고 실행됨.
public void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html; charset=utf-8");
QADao dao = QADao.getInstance();
PrintWriter out = resp.getWriter();
String command = req.getParameter("command");
/*// QAList(리스트)
if (command.equals("list")) {
int searchfor = Integer.parseInt(req.getParameter("searchfor"));
String search ="";
if(searchfor!=0) {
search = req.getParameter("foundered");
}
List<QADto> QAList = QAmemberDao.getList(searchfor,search);
req.setAttribute("QAList", QAList);
// 다음 view 이동
dispatch("/JSP/QAList.jsp", req, resp);
*/
//화면에 보여질 게시글의 개수를 지정
if(command.equals("list")) {
int searchfor = Integer.parseInt(req.getParameter("searchfor"));
System.out.println("searchfor: " +searchfor);
String search = "";
if(searchfor!=0) {
search = req.getParameter("findword");
search = search;
}
System.out.println("search: " +search);
int pasgeSize = 10;
//현재 보여지고 있는 페이지의 넘버값을 읽어드림
String pageNum = req.getParameter("pageNum");
//null 처리
if (pageNum == null) {
pageNum = "1";
}
//전체 게시글의 갯수를 파악
int count = 0;
// jsp 내에서 보여질 넘버링 숫자값을 저장하는 변수
int number = 0;
//현재 보여지고 있는 페이지 문자를 숫자로 형변환
int currentPage = Integer.parseInt(pageNum);
//전체 게시글의 갯수를 가져와야 하기에 데이터베이스 객체 생성
QADao Qdao = new QADao();
count = Qdao.getAllCount(searchfor,search);
System.out.println(count);
//현재 보여질 페이지 시작 번호를 설정
int startRow = 1;
if(currentPage!= 1) {
// Db count 내용 10개씩 잘라서 받아오는 계산
startRow = (currentPage - 1) * pasgeSize + 1;
}
int endRow = currentPage * pasgeSize;
//검색 List
List<QADto> list = new ArrayList<>();
if(searchfor == 0) {
list = dao.getQAList(startRow, endRow, searchfor, null);
}else if(searchfor == 1) {
list = dao.getQAList(startRow, endRow, searchfor, search);
}else if(searchfor == 2) {
list = dao.getQAList(startRow, endRow, searchfor, search);
}else if(searchfor == 3) {
list = dao.getQAList(startRow, endRow, searchfor, search);
}
req.setAttribute("count", count+"");
req.setAttribute("currentPage", currentPage+"");
req.setAttribute("list", list);
req.setAttribute("search", searchfor+"");
req.setAttribute("str", search);
RequestDispatcher dis = req.getRequestDispatcher("/JSP/QAList.jsp");
dis.forward(req, resp);
// 추가
} else if (command.equals("regist_add")) {
// 로그인 후 Dto에 저장된 객체값들을 가져옴.
String id = req.getParameter("id");
String title = req.getParameter("title");
String content = req.getParameter("content");
QADto QAadd = new QADto(id, title, content);
if (dao.QAinsert(QAadd)) {
resp.sendRedirect("QAController?command=list&searchfor=0");
} else {
dispatch("JSP/QAwrite.jsp", req, resp);
}
// QADetail (개인정보)
} else if (command.equals("QAupdate")) {
int seq = Integer.parseInt(req.getParameter("seq"));
// Parameter에서는 int 숫자를 받을떄 형변환을 해줘야한다.
String title = req.getParameter("title");
String content = req.getParameter("content");
boolean result = dao.QABbupdate(seq, title, content);
if (result == true) {
System.out.println("result was true");
out.println("<script type=\"text/javascript\">");
out.println("alert('수정되었습니다.');");
out.println("location = \"QAController?command=list&searchfor=0\"");
out.println("</script>");
} else {
out.println("<script>alert('오류가 생겼습니다.');</script>");
}
// QAdelete(삭제)
} else if (command.equals("QAdelete")) {
int seq = Integer.parseInt(req.getParameter("seq"));
boolean result = dao.QAdelete(seq);
if (result == true) {
out.println("<script type=\"text/javascript\">");
out.println("alert('삭제되었습니다.');");
out.println("location = \"QAController?command=list&searchfor=0\"");
out.println("</script>");
} else {
out.println("<script>alert('오류가 생겼습니다.');</script>");
}
// answer (댓글)
} else if (command.equals("QAanswer")) {
int seq = Integer.parseInt(req.getParameter("seq"));
String id = req.getParameter("id");
String title = req.getParameter("title");
String content = req.getParameter("content");
// id, name , address 하나라도 작성하지 않으면 작동안됨.
if (isNull(id) || isNull(title) || isNull(content)) {
System.out.println("모든 정보를 입력하지 않았음");
// 다시 작성하라고 QAwrite view로 넘어감
resp.sendRedirect("QAController?command=list&searchfor=0"); // 입력만하고 다음 view 이동할떄 사용
}
// 쿼리 처리 데이터 받아옴.
QADto dto = new QADto(id, title, content);
boolean result = dao.QAanswer(seq, dto);
if (!result) {
System.out.println("추가하지 못했습니다");
resp.sendRedirect("../QAwrite.jsp");
}
resp.sendRedirect("QAController?command=list&searchfor=0"); // 입력만하고 다음 view 이동할떄 사용
} else if(command.equals("reply")) {
int ref = Integer.parseInt(req.getParameter("ref"));
String id = req.getParameter("id");
String content = req.getParameter("content");
String parent = req.getParameter("parent");
int parseq = Integer.parseInt(parent);
System.out.println(ref +" "+ id + " " + content + " " + parent);
ReplyDto dto = new ReplyDto(id, ref, parseq, content);
boolean result = dao.reply(dto);
if(result) {
out.println("<script>alert(\'답변이 등록되었습니다.\'); location=\'" + req.getContextPath()+ "/JSP/QADetail.jsp?seq="+ ref+ "\'</script>");
}else {
out.println("<script>alert(\'문제가 생겼습니다.\'); location=\'" + req.getContextPath()+ "/JSP/QADetail.jsp?seq="+ ref+ "\'</script>");
}
//다시
}else if(command.equals("repdelete")) {
int seq = Integer.parseInt(req.getParameter("seq"));
int ref = Integer.parseInt(req.getParameter("ref"));
boolean result = dao.repdelete(seq, ref);
if (result == true) {
out.println("<script>alert(\'답변이 삭제되었습니다.\'); location=\'" + req.getContextPath()+ "/JSP/QADetail.jsp?seq="+ ref+ "\'</script>");
} else {
out.println("<script>alert(\'문제가 생겼습니다.\'); location=\'" + req.getContextPath()+ "/JSP/QADetail.jsp?seq="+ ref+ "\'</script>");
}
}else if(command.equals("repupdate")) {
int seq = Integer.parseInt(req.getParameter("seq"));
String content = req.getParameter("content");
int ref = Integer.parseInt(req.getParameter("ref"));
boolean result = dao.repupdate(seq, content);
if (result == true) {
out.println("<script>alert(\'답변이 수정되었습니다.\'); location=\'" + req.getContextPath()+ "/JSP/QADetail.jsp?seq="+ ref+ "\'</script>");
} else {
out.println("<script>alert(\'문제가 생겼습니다.\'); location=\'" + req.getContextPath()+ "/JSP/QADetail.jsp?seq="+ ref+ "\'</script>");
}
}
}
// 이동
public void dispatch(String urls, HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
RequestDispatcher dispatch = req.getRequestDispatcher(urls);
dispatch.forward(req, resp);
}
// 껍데기
public boolean isNull(String str) {
return str == null || str.trim().equals("");
}
}
package Controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.*;
import Dao.ReserveDao;
import Dto.MemberDto;
import Dto.ReserveDto;
@SuppressWarnings("serial")
public class ReserveController extends HttpServlet{
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("doprocess please");
doProcess(req, resp);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("doprocess please");
doProcess(req, resp);
}
public void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
resp.setContentType("text/html; charset=utf-8");
System.out.println("doprocess please");
String command = req.getParameter("command");
ReserveDao dao = ReserveDao.getInstance();
PrintWriter out = resp.getWriter();
HttpSession session = req.getSession();
MemberDto logindto = (MemberDto)session.getAttribute("kh_member");
if(command.equals("list")) {
String month = this.formatTwo(req.getParameter("month"));
String year = req.getParameter("year");
System.out.println(year+month);
List<String> list;
if(logindto != null) {
list = dao.getCalendarList(logindto.getId(), year+month);
}else {
list = dao.getCalendarList("", year+month);
}
String json ="[";
for (int i = 0; i < list.size(); i++) {
json += list.get(i);
if(i < list.size()-1) {
json += ",";
}
}
json += "]";
resp.getWriter().write(json);
}else if(command.equals("reservepage")) {
this.dispatch("./JSP/Reserve.jsp", req, resp);
}else if(command.equals("reserve")) {
String title= req.getParameter("title");
String date = req.getParameter("date");
String time= req.getParameter("time");
String content= req.getParameter("content");
System.out.println(title);
date = date.replaceAll("-", "");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.parseInt(date.substring(0, 4)));
cal.set(Calendar.MONTH, Integer.parseInt(date.substring(4, 6))-1);
cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(date.substring(6, 8)));
System.out.println(cal.getTime());
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
System.out.println(dayOfWeek);
if(dayOfWeek == 1 || dayOfWeek == 7) {
resp.sendRedirect("./JSP/ErrorPage.jsp?error=weekend");
}else {
date += time;
content = content.replace("\r\n", " ");
boolean result1 =dao.checkpossible(date);
if(result1) {
ReserveDto tmp = new ReserveDto(logindto.getId(), title.trim(), content.trim(), date.trim());
boolean result2 = dao.makeSchedule(tmp);
resp.sendRedirect("./JSP/Calendar.jsp");
}else {
resp.sendRedirect("./JSP/ErrorPage.jsp?error=schedule");
}
}
}else if(command.equals("detail")) {
int seq = Integer.parseInt(req.getParameter("seq"));
ReserveDto dto = dao.getSchedule(seq);
req.setAttribute("dto", dto);
this.dispatch("/JSP/ReserveDetail.jsp", req, resp);
}else if(command.equals("delete")) {
int seq = Integer.parseInt(req.getParameter("seq"));
boolean result = dao.deleteschedule(seq);
if(result) {
out.println("<script>alert(\"성공적으로 삭제되었습니다\"); location = '/KH_SecondPJ/JSP/Calendar.jsp';</script>") ;
}else {
out.println("<script>alert(\"삭제중에 문제가 생겼습니다.\"); location = '/KH_SecondPJ/JSP/Calendar.jsp</script>';") ;
}
}else if(command.equals("update")) {
int seq = Integer.parseInt(req.getParameter("seq"));
ReserveDto dto = dao.getSchedule(seq);
req.setAttribute("dto", dto);
this.dispatch("/JSP/ReserveUpdate.jsp", req, resp);
/*if(result) {
out.println("<script>alert(\"성공적으로 삭제되었습니다\"); location = '/KH_SecondPJ/JSP/Calendar.jsp';</script>") ;
}else {
out.println("<script>alert(\"삭제중에 문제가 생겼습니다.\"); location = '/KH_SecondPJ/JSP/Calendar.jsp</script>';") ;
}*/
}else if(command.equals("mylist")) {
System.out.println("please work god light");
List<ReserveDto> list = dao.mylist(logindto.getId());
if(list.size()== 0) {
out.println("<script>alert(\"예약된 상담이 존재하지 않습니다.\"); location = '/KH_SecondPJ/JSP/Calendar.jsp';</script>") ;
}else {
req.setAttribute("mylist", list);
this.dispatch("/JSP/MyReserve.jsp", req, resp);
}
/*if(result) {
out.println("<script>alert(\"성공적으로 삭제되었습니다\"); location = '/KH_SecondPJ/JSP/Calendar.jsp';</script>") ;
}else {
out.println("<script>alert(\"삭제중에 문제가 생겼습니다.\"); location = '/KH_SecondPJ/JSP/Calendar.jsp</script>';") ;
}*/
}else if(command.equals("updateAF")) {
int seq = Integer.parseInt(req.getParameter("seq"));
String titlenew= req.getParameter("title");
String datenew = req.getParameter("date");
String timenew= req.getParameter("time");
String contentnew= req.getParameter("content");
datenew = datenew.replaceAll("-", "");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.parseInt(datenew.substring(0, 4)));
cal.set(Calendar.MONTH, Integer.parseInt(datenew.substring(4, 6))-1);
cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(datenew.substring(6, 8)));
System.out.println(cal.getTime());
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
System.out.println(dayOfWeek);
if(dayOfWeek == 1 || dayOfWeek == 7) {
resp.sendRedirect("./JSP/ErrorPage.jsp?error=weekend&");
}else {
datenew += timenew;
contentnew = contentnew.replace("\r\n", " ");
boolean result1 =dao.checkpossible(datenew);
if(result1) {
boolean result2 = dao.updateschedule(seq, new ReserveDto(logindto.getId(), titlenew.trim(), contentnew.trim(), datenew.trim()));
if(result2) {
out.println("<script>alert(\"성공적으로 예약이 변경되었습니다\"); location = '/KH_SecondPJ/JSP/Calendar.jsp';</script>") ;
}else {
out.println("<script>alert(\"예약 변경중에 문제가 생겼습니다.\"); location = '/KH_SecondPJ/JSP/Calendar.jsp</script>") ;
}
}else {
resp.sendRedirect("./JSP/ErrorPage.jsp?error=schedule");
}
}
}
}
public void dispatch(String urls, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
RequestDispatcher dispatch = req.getRequestDispatcher(urls);
dispatch.forward(req, resp);
}
public String formatTwo(String month) {
if(month.length()== 1) {
month = "0"+month;
}
return month;
}
}
'JavaScript mini Project > Project java code ' 카테고리의 다른 글
Mem,Pbs,QA,Reserve - Dto(MVC2) (0) | 2018.09.30 |
---|---|
Mem,Pbs,QA,Reserve - Dao (MVC2) (0) | 2018.09.30 |
Location (0) | 2018.09.26 |
Q&A List (0) | 2018.09.26 |
About (0) | 2018.09.26 |