+++ .classpath
... | ... | @@ -0,0 +1,33 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<classpath> | |
3 | + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | |
4 | + <attributes> | |
5 | + <attribute name="maven.pomderived" value="true"/> | |
6 | + </attributes> | |
7 | + </classpathentry> | |
8 | + <classpathentry kind="src" output="target/classes" path="src/main/java"> | |
9 | + <attributes> | |
10 | + <attribute name="optional" value="true"/> | |
11 | + <attribute name="maven.pomderived" value="true"/> | |
12 | + </attributes> | |
13 | + </classpathentry> | |
14 | + <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0"> | |
15 | + <attributes> | |
16 | + <attribute name="owner.project.facets" value="jst.web"/> | |
17 | + </attributes> | |
18 | + </classpathentry> | |
19 | + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | |
20 | + <attributes> | |
21 | + <attribute name="optional" value="true"/> | |
22 | + <attribute name="maven.pomderived" value="true"/> | |
23 | + <attribute name="test" value="true"/> | |
24 | + </attributes> | |
25 | + </classpathentry> | |
26 | + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | |
27 | + <attributes> | |
28 | + <attribute name="maven.pomderived" value="true"/> | |
29 | + <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> | |
30 | + </attributes> | |
31 | + </classpathentry> | |
32 | + <classpathentry kind="output" path="target/classes"/> | |
33 | +</classpath> |
+++ .project
... | ... | @@ -0,0 +1,37 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<projectDescription> | |
3 | + <name>JSP_Board</name> | |
4 | + <comment></comment> | |
5 | + <projects> | |
6 | + </projects> | |
7 | + <buildSpec> | |
8 | + <buildCommand> | |
9 | + <name>org.eclipse.jdt.core.javabuilder</name> | |
10 | + <arguments> | |
11 | + </arguments> | |
12 | + </buildCommand> | |
13 | + <buildCommand> | |
14 | + <name>org.eclipse.wst.common.project.facet.core.builder</name> | |
15 | + <arguments> | |
16 | + </arguments> | |
17 | + </buildCommand> | |
18 | + <buildCommand> | |
19 | + <name>org.eclipse.wst.validation.validationbuilder</name> | |
20 | + <arguments> | |
21 | + </arguments> | |
22 | + </buildCommand> | |
23 | + <buildCommand> | |
24 | + <name>org.eclipse.m2e.core.maven2Builder</name> | |
25 | + <arguments> | |
26 | + </arguments> | |
27 | + </buildCommand> | |
28 | + </buildSpec> | |
29 | + <natures> | |
30 | + <nature>org.eclipse.m2e.core.maven2Nature</nature> | |
31 | + <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> | |
32 | + <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> | |
33 | + <nature>org.eclipse.wst.common.project.facet.core.nature</nature> | |
34 | + <nature>org.eclipse.jdt.core.javanature</nature> | |
35 | + <nature>org.eclipse.wst.jsdt.core.jsNature</nature> | |
36 | + </natures> | |
37 | +</projectDescription> |
+++ .settings/.jsdtscope
... | ... | @@ -0,0 +1,12 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<classpath> | |
3 | + <classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="src/main/webapp"/> | |
4 | + <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/> | |
5 | + <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject"> | |
6 | + <attributes> | |
7 | + <attribute name="hide" value="true"/> | |
8 | + </attributes> | |
9 | + </classpathentry> | |
10 | + <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/> | |
11 | + <classpathentry kind="output" path=""/> | |
12 | +</classpath> |
+++ .settings/org.eclipse.core.resources.prefs
... | ... | @@ -0,0 +1,3 @@ |
1 | +eclipse.preferences.version=1 | |
2 | +encoding//src/main/java/config/EncodingFiter.java=UTF-8 | |
3 | +encoding//src/main/java/control/MemberServlet.java=UTF-8 |
+++ .settings/org.eclipse.jdt.core.prefs
... | ... | @@ -0,0 +1,11 @@ |
1 | +eclipse.preferences.version=1 | |
2 | +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | |
3 | +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | |
4 | +org.eclipse.jdt.core.compiler.compliance=1.8 | |
5 | +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | |
6 | +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | |
7 | +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | |
8 | +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |
9 | +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | |
10 | +org.eclipse.jdt.core.compiler.release=disabled | |
11 | +org.eclipse.jdt.core.compiler.source=1.8 |
+++ .settings/org.eclipse.m2e.core.prefs
... | ... | @@ -0,0 +1,4 @@ |
1 | +activeProfiles= | |
2 | +eclipse.preferences.version=1 | |
3 | +resolveWorkspaceProjects=true | |
4 | +version=1 |
+++ .settings/org.eclipse.wst.common.component
... | ... | @@ -0,0 +1,9 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> | |
2 | + <wb-module deploy-name="WebTest-0.0.1-SNAPSHOT"> | |
3 | + <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> | |
4 | + <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> | |
5 | + <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> | |
6 | + <property name="java-output-path" value="/JSP_Board/build/classes"/> | |
7 | + <property name="context-root" value="WebTest"/> | |
8 | + </wb-module> | |
9 | +</project-modules> |
+++ .settings/org.eclipse.wst.common.project.facet.core.xml
... | ... | @@ -0,0 +1,10 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<faceted-project> | |
3 | + <runtime name="Apache Tomcat v9.0"/> | |
4 | + <fixed facet="jst.web"/> | |
5 | + <fixed facet="wst.jsdt.web"/> | |
6 | + <fixed facet="java"/> | |
7 | + <installed facet="jst.web" version="3.1"/> | |
8 | + <installed facet="wst.jsdt.web" version="1.0"/> | |
9 | + <installed facet="java" version="1.8"/> | |
10 | +</faceted-project> |
+++ .settings/org.eclipse.wst.jsdt.ui.superType.container
... | ... | @@ -0,0 +1,1 @@ |
1 | +org.eclipse.wst.jsdt.launching.baseBrowserLibrary(No newline at end of file) |
+++ .settings/org.eclipse.wst.jsdt.ui.superType.name
... | ... | @@ -0,0 +1,1 @@ |
1 | +Window(No newline at end of file) |
+++ .settings/org.eclipse.wst.validation.prefs
... | ... | @@ -0,0 +1,2 @@ |
1 | +disabled=06target | |
2 | +eclipse.preferences.version=1 |
+++ build/classes/config/Database.class
Binary file is not shown |
+++ build/classes/config/EncodingFiter.class
Binary file is not shown |
+++ build/classes/control/MemberServlet.class
Binary file is not shown |
+++ build/classes/model/MemberDAO.class
Binary file is not shown |
+++ build/classes/model/MemberDTO.class
Binary file is not shown |
+++ build/classes/model/ReplyDTO.class
Binary file is not shown |
+++ src/main/java/config/Database.class
Binary file is not shown |
+++ src/main/java/config/Database.java
... | ... | @@ -0,0 +1,28 @@ |
1 | +package config; | |
2 | + | |
3 | +import java.sql.Connection; | |
4 | +import java.sql.DriverManager; | |
5 | + | |
6 | + | |
7 | +public class Database | |
8 | +{ | |
9 | + private static String dbHost = "db.asin21.com"; | |
10 | + private static String dbUser = "demo07"; | |
11 | + private static String dbPass = "demo07!"; | |
12 | + private static String dbName = "db_demo07"; | |
13 | + | |
14 | + private static String dbDriver = "com.mysql.jdbc.Driver"; | |
15 | + private static String dbUrl = "jdbc:mysql://" + dbHost + "/" + dbName + "?characterEncoding=UTF-8"; | |
16 | + | |
17 | + | |
18 | + public static Connection getConnection() { | |
19 | + try { | |
20 | + Class.forName(dbDriver); | |
21 | + return DriverManager.getConnection(dbUrl, dbUser, dbPass); | |
22 | + } | |
23 | + catch (Exception e) { | |
24 | + e.printStackTrace(); | |
25 | + return null; | |
26 | + } | |
27 | + } | |
28 | +} |
+++ src/main/java/config/EncodingFiter.class
Binary file is not shown |
+++ src/main/java/config/EncodingFiter.java
... | ... | @@ -0,0 +1,45 @@ |
1 | +package config; | |
2 | + | |
3 | +import java.io.IOException; | |
4 | +import java.sql.Connection; | |
5 | +import javax.servlet.Filter; | |
6 | +import javax.servlet.FilterChain; | |
7 | +import javax.servlet.FilterConfig; | |
8 | +import javax.servlet.ServletException; | |
9 | +import javax.servlet.ServletRequest; | |
10 | +import javax.servlet.ServletResponse; | |
11 | +import javax.servlet.annotation.WebFilter; | |
12 | + | |
13 | +@WebFilter({ "/*" }) | |
14 | +public class EncodingFiter implements Filter { | |
15 | + private final String charset = "utf-8"; | |
16 | + | |
17 | + public EncodingFiter() { | |
18 | + System.out.println("Fiter Created!"); | |
19 | + } | |
20 | + | |
21 | + public void destroy() { | |
22 | + System.out.println("System Down!"); | |
23 | + } | |
24 | + | |
25 | + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |
26 | + throws IOException, ServletException { | |
27 | + System.out.println("Servlet Auto Start Successfuly"); | |
28 | + | |
29 | + request.setCharacterEncoding("utf-8"); | |
30 | + response.setContentType("text/html; charset=utf-8"); | |
31 | + response.setCharacterEncoding("utf-8"); | |
32 | + | |
33 | + chain.doFilter(request, response); | |
34 | + } | |
35 | + | |
36 | + public void init(FilterConfig fConfig) throws ServletException { | |
37 | + System.out.println("system Start"); | |
38 | + Connection conn = Database.getConnection(); | |
39 | + if (conn != null) { | |
40 | + System.out.println(conn + " : DB Connention Success!"); | |
41 | + } else { | |
42 | + System.out.println("DB Connention Fail!!"); | |
43 | + } | |
44 | + } | |
45 | +} |
+++ src/main/java/control/MemberServlet.java
... | ... | @@ -0,0 +1,313 @@ |
1 | +package control; | |
2 | + | |
3 | +import java.io.File; | |
4 | +import java.io.IOException; | |
5 | +import java.io.PrintWriter; | |
6 | +import java.text.SimpleDateFormat; | |
7 | +import java.util.Calendar; | |
8 | +import java.util.Date; | |
9 | +import java.util.HashMap; | |
10 | +import java.util.List; | |
11 | +import java.util.Map; | |
12 | +import javax.servlet.RequestDispatcher; | |
13 | +import javax.servlet.ServletException; | |
14 | +import javax.servlet.annotation.WebServlet; | |
15 | +import javax.servlet.http.HttpServlet; | |
16 | +import javax.servlet.http.HttpServletRequest; | |
17 | +import javax.servlet.http.HttpServletResponse; | |
18 | +import model.MemberDAO; | |
19 | +import model.MemberDTO; | |
20 | +import model.ReplyDTO; | |
21 | + | |
22 | +/** | |
23 | + * Servlet implementation class MemberServlet | |
24 | + */ | |
25 | +@WebServlet({ "/Member/*" }) | |
26 | +public class MemberServlet extends HttpServlet { | |
27 | + private static final long serialVersionUID = 1L; | |
28 | + | |
29 | + /** | |
30 | + * @see HttpServlet#HttpServlet() | |
31 | + */ | |
32 | + public MemberServlet() { | |
33 | + super(); | |
34 | + // TODO Auto-generated constructor stub | |
35 | + } | |
36 | + | |
37 | + /** | |
38 | + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse | |
39 | + * response) | |
40 | + */ | |
41 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) | |
42 | + throws ServletException, IOException { | |
43 | + String url = request.getRequestURL().toString(); | |
44 | + String viewPage = null; | |
45 | + | |
46 | + MemberDAO dao = new MemberDAO(); | |
47 | + PrintWriter out = response.getWriter(); | |
48 | + | |
49 | + if (url.indexOf("list.do") != -1) { | |
50 | + int pageStart; | |
51 | + String option = request.getParameter("option"); | |
52 | + String searchText = request.getParameter("searchText"); | |
53 | + | |
54 | + String pageStart1 = request.getParameter("pageStart"); | |
55 | + | |
56 | + if (pageStart1 == null) { | |
57 | + pageStart = 0; | |
58 | + } else { | |
59 | + pageStart = Integer.parseInt(request.getParameter("pageStart")); | |
60 | + } | |
61 | + | |
62 | + int countFor = dao.getCountFor(option, searchText); | |
63 | + | |
64 | + List<MemberDTO> list = dao.MemberList(option, searchText, pageStart); | |
65 | + Map<String, Object> map = new HashMap<String, Object>(); | |
66 | + | |
67 | + map.put("list", list); | |
68 | + map.put("count", Integer.valueOf(list.size())); | |
69 | + request.setAttribute("map", map); | |
70 | + | |
71 | + viewPage = "/view/list.jsp"; | |
72 | + RequestDispatcher goUrl = request.getRequestDispatcher(viewPage); | |
73 | + goUrl.forward(request, response); | |
74 | + } else if (url.indexOf("content.do") != -1) { | |
75 | + int no = Integer.parseInt(request.getParameter("no")); | |
76 | + request.setAttribute("no", Integer.valueOf(no)); | |
77 | + | |
78 | + List<ReplyDTO> list2 = dao.ReplyList(no); | |
79 | + Map<String, Object> map = new HashMap<String, Object>(); | |
80 | + | |
81 | + map.put("list2", list2); | |
82 | + map.put("count", Integer.valueOf(list2.size())); | |
83 | + System.out.println(map); | |
84 | + request.setAttribute("map", map); | |
85 | + | |
86 | + viewPage = "/view/content.jsp"; | |
87 | + RequestDispatcher goUrl = request.getRequestDispatcher(viewPage); | |
88 | + goUrl.forward(request, response); | |
89 | + | |
90 | + int noForCount = Integer.parseInt(request.getParameter("no")); | |
91 | + int view = Integer.parseInt(request.getParameter("view")); | |
92 | + | |
93 | + dao.setCountUpdate(noForCount, view); | |
94 | + | |
95 | + } else if (url.indexOf("write.do") != -1) { | |
96 | + | |
97 | + viewPage = "/view/write.jsp"; | |
98 | + RequestDispatcher goUrl = request.getRequestDispatcher(viewPage); | |
99 | + goUrl.forward(request, response); | |
100 | + } else if (url.indexOf("insert") != -1) { | |
101 | + | |
102 | + request.setCharacterEncoding("UTF-8"); | |
103 | + response.setCharacterEncoding("UTF-8"); | |
104 | + response.setContentType("text/html; charset=utf-8"); | |
105 | + | |
106 | + String writer = request.getParameter("inputWriter"); | |
107 | + if (writer.equals("")) { | |
108 | + writer = "Anonymous"; | |
109 | + } | |
110 | + | |
111 | + String title = request.getParameter("inputTitle"); | |
112 | + String contents = request.getParameter("inputContents"); | |
113 | + Date date = new Date(); | |
114 | + SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd"); | |
115 | + String strdate = simpleDate.format(date); | |
116 | + | |
117 | + Calendar cal = Calendar.getInstance(); | |
118 | + | |
119 | + int mondifyedMonth = cal.get(2) + 1; | |
120 | + | |
121 | + String inputDate = String.valueOf(cal.get(1)) + "-" + mondifyedMonth + "-" + cal.get(5); | |
122 | + | |
123 | + int view = 1; | |
124 | + | |
125 | + boolean result = false; | |
126 | + result = dao.setInsert(writer, title, contents, view, inputDate); | |
127 | + | |
128 | + if (result) { | |
129 | + out.println("<script>alert('등록 완료')</script>"); | |
130 | + viewPage = "list.do"; | |
131 | + } else { | |
132 | + out.println("<script>alert('등록 실패')</script>"); | |
133 | + viewPage = "list.do"; | |
134 | + } | |
135 | + | |
136 | + out.println("<script>location.href='list.do'</script>"); | |
137 | + | |
138 | + } else if (url.indexOf("delete.do") != -1) { | |
139 | + | |
140 | + int no = Integer.parseInt(request.getParameter("no")); | |
141 | + System.out.println(no); | |
142 | + boolean result = false; | |
143 | + result = dao.setDelete(no); | |
144 | + | |
145 | + if (result) { | |
146 | + out.println("<script>alert('삭제 성공')</script>"); | |
147 | + viewPage = "list.do"; | |
148 | + } else { | |
149 | + out.println("<script>alert('삭제 실패')</script>"); | |
150 | + viewPage = "list.do"; | |
151 | + } | |
152 | + | |
153 | + out.println("<script>location.href='list.do'</script>"); | |
154 | + | |
155 | + } else if (url.indexOf("update.do") != -1) { | |
156 | + | |
157 | + viewPage = "/view/update.jsp"; | |
158 | + RequestDispatcher goUrl = request.getRequestDispatcher(viewPage); | |
159 | + goUrl.forward(request, response); | |
160 | + | |
161 | + } else if (url.indexOf("updateComplite.do") != -1) { | |
162 | + | |
163 | + int no = Integer.parseInt(request.getParameter("no")); | |
164 | + String title = request.getParameter("changeTitle"); | |
165 | + String writer = request.getParameter("changeWriter"); | |
166 | + String contents = request.getParameter("changeContents"); | |
167 | + System.out.println(no); | |
168 | + boolean result = false; | |
169 | + result = dao.setUpdate(no, title, writer, contents); | |
170 | + | |
171 | + if (result) { | |
172 | + out.println("<script>alert('수정 성공')</script>"); | |
173 | + viewPage = "list.do"; | |
174 | + } else { | |
175 | + out.println("<script>alert('수정 실패')</script>"); | |
176 | + viewPage = "list.do"; | |
177 | + } | |
178 | + | |
179 | + out.println("<script>location.href='list.do'</script>"); | |
180 | + } else if (url.indexOf("download.do") != -1) { | |
181 | + | |
182 | + System.out.print("다운로드.두 로 옴"); | |
183 | + String filePath = request.getRealPath("/download"); | |
184 | + File file = new File(String.valueOf(filePath) + "/" + request.getParameter("file")); | |
185 | + | |
186 | + } else if (url.indexOf("replyInsert.do") != -1) { | |
187 | + | |
188 | + String replyWriter = request.getParameter("replyWriter"); | |
189 | + String replyContent = request.getParameter("replyContent"); | |
190 | + int no = Integer.parseInt(request.getParameter("no")); | |
191 | + int password = Integer.parseInt(request.getParameter("password")); | |
192 | + int passwordCheck = Integer.parseInt(request.getParameter("passwordCheck")); | |
193 | + | |
194 | + if (password == passwordCheck) { | |
195 | + boolean result = dao.setReplyInsert(replyWriter, replyContent, no, password); | |
196 | + | |
197 | + if (result) { | |
198 | + out.println("<script>alert('등록 성공')</script>"); | |
199 | + response.sendRedirect("content.do?no=" + no); | |
200 | + } else { | |
201 | + out.println("<script>alert('등록 실패')</script>"); | |
202 | + response.sendRedirect("content.do?no=" + no); | |
203 | + } | |
204 | + } else { | |
205 | + out.println("<script>alert('비밀번호가 일치하지 않습니다.')</script>"); | |
206 | + out.println("<script>history.go(-1)</script>"); | |
207 | + } | |
208 | + | |
209 | + } else if (url.indexOf("replyUpdate.do") != -1) { | |
210 | + | |
211 | + int inputPassword, no = Integer.parseInt(request.getParameter("no")); | |
212 | + int upNo = Integer.parseInt(request.getParameter("upNo")); | |
213 | + String changedReplyWriter = request.getParameter("changedReplyWriter"); | |
214 | + String changedReplyContent = request.getParameter("changedReplyContent"); | |
215 | + | |
216 | + int bringPassword = dao.getPassword(no); | |
217 | + String inputPassword1 = request.getParameter("inputPassword"); | |
218 | + | |
219 | + if (inputPassword1.equals("")) { | |
220 | + inputPassword = 0; | |
221 | + } else { | |
222 | + inputPassword = Integer.parseInt(request.getParameter("inputPassword")); | |
223 | + } | |
224 | + if (inputPassword == 0) { | |
225 | + out.println("<script>alert('비밀번호를 입력하세요!')</script>"); | |
226 | + out.println("<script>history.go(-1)</script>"); | |
227 | + } else if (bringPassword == inputPassword) { | |
228 | + boolean result = dao.setUpdateReply(no, changedReplyWriter, changedReplyContent); | |
229 | + if (result) { | |
230 | + out.println("<script>alert('수정 성공')</script>"); | |
231 | + response.sendRedirect("content.do?no=" + upNo); | |
232 | + } else { | |
233 | + out.println("<script>alert('수정 실패')</script>"); | |
234 | + response.sendRedirect("content.do?no=" + upNo); | |
235 | + } | |
236 | + } else { | |
237 | + out.println("<script>alert('비밀번호가 일치하지 않습니다.!')</script>"); | |
238 | + out.println("<script>history.go(-1)</script>"); | |
239 | + } | |
240 | + | |
241 | + } else if (url.indexOf("replyDelete.do") != -1) { | |
242 | + | |
243 | + int inputPassword, no = Integer.parseInt(request.getParameter("no")); | |
244 | + int upNo = Integer.parseInt(request.getParameter("upNo")); | |
245 | + int bringPassword = dao.getPassword(no); | |
246 | + String inputPassword1 = request.getParameter("inputPassword"); | |
247 | + | |
248 | + if (inputPassword1.equals("")) { | |
249 | + inputPassword = 0; | |
250 | + } else { | |
251 | + inputPassword = Integer.parseInt(request.getParameter("inputPassword")); | |
252 | + } | |
253 | + if (inputPassword != bringPassword) { | |
254 | + out.println("<script>alert('비밀번호가 일치하지 않습니다.!')</script>"); | |
255 | + out.println("<script>history.go(-1)</script>"); | |
256 | + } else { | |
257 | + boolean result = dao.setReplyDelete(no); | |
258 | + if (result) { | |
259 | + response.sendRedirect("content.do?no=" + upNo); | |
260 | + } else { | |
261 | + response.sendRedirect("content.do?no=" + upNo); | |
262 | + } | |
263 | + } | |
264 | + } else if (url.indexOf("answerWriteFront.do") != -1) { | |
265 | + | |
266 | + viewPage = "/view/answerWriteFront.jsp"; | |
267 | + RequestDispatcher goUrl = request.getRequestDispatcher(viewPage); | |
268 | + goUrl.forward(request, response); | |
269 | + | |
270 | + } else if (url.indexOf("answerWriteBack") != -1) { | |
271 | + | |
272 | + int motherNo = Integer.parseInt(request.getParameter("motherNo")); | |
273 | + String answerWriter = request.getParameter("answerWriter"); | |
274 | + String answerTitle = request.getParameter("answerTitle"); | |
275 | + String answerContent = request.getParameter("answerContents"); | |
276 | + | |
277 | + Date date = new Date(); | |
278 | + SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd"); | |
279 | + String strdate = simpleDate.format(date); | |
280 | + | |
281 | + Calendar cal = Calendar.getInstance(); | |
282 | + | |
283 | + int mondifyedMonth = cal.get(2) + 1; | |
284 | + | |
285 | + String inputDate = String.valueOf(cal.get(1)) + "-" + mondifyedMonth + "-" + cal.get(5); | |
286 | + | |
287 | + boolean result = dao.setAnswerInsert(answerWriter, answerTitle, answerContent, motherNo, inputDate); | |
288 | + | |
289 | + if (result) { | |
290 | + out.println("<script>alert('등록 성공')</script>"); | |
291 | + viewPage = "list.do"; | |
292 | + } else { | |
293 | + out.println("<script>alert('등록 실패')</script>"); | |
294 | + viewPage = "list.do"; | |
295 | + } | |
296 | + out.println("<script>location.href='list.do'</script>"); | |
297 | + | |
298 | + } else { | |
299 | + | |
300 | + System.out.println("Servlet else"); | |
301 | + } | |
302 | + } | |
303 | + | |
304 | + /** | |
305 | + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse | |
306 | + * response) | |
307 | + */ | |
308 | + protected void doPost(HttpServletRequest request, HttpServletResponse response) | |
309 | + throws ServletException, IOException { | |
310 | + doGet(request, response); | |
311 | + } | |
312 | + | |
313 | +} |
+++ src/main/java/model/MemberDAO.java
... | ... | @@ -0,0 +1,671 @@ |
1 | +package model; | |
2 | + | |
3 | +import config.Database; | |
4 | +import java.sql.Connection; | |
5 | +import java.sql.PreparedStatement; | |
6 | +import java.sql.ResultSet; | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.List; | |
9 | +import model.MemberDTO; | |
10 | +import model.ReplyDTO; | |
11 | + | |
12 | +public class MemberDAO { | |
13 | + | |
14 | + | |
15 | + Connection conn; | |
16 | + PreparedStatement pstmt; | |
17 | + PreparedStatement pstmt2; | |
18 | + PreparedStatement pstmt3; | |
19 | + PreparedStatement pstmt4; | |
20 | + PreparedStatement pstmt5; | |
21 | + ResultSet rs; | |
22 | + ResultSet rs2; | |
23 | + ResultSet rs3; | |
24 | + ResultSet rs4; | |
25 | + ResultSet rs5; | |
26 | + | |
27 | + public List<MemberDTO> MemberList(String option, String searchText, int pageStart) { | |
28 | + List<MemberDTO> list = new ArrayList<MemberDTO>(); | |
29 | + | |
30 | + conn = null; | |
31 | + pstmt = null; | |
32 | + rs = null; | |
33 | + String query = ""; | |
34 | + String query2 = "update user set listNum = ?"; | |
35 | + | |
36 | + int data = 0; | |
37 | + if (searchText == null) { | |
38 | + query = "select * from user order by listNum desc, depth asc limit ?, 7"; | |
39 | + data = 0; | |
40 | + } else if (option.equals("title")) { | |
41 | + query = "select * from user where title like ? order by no desc limit ?, 7"; | |
42 | + data = 1; | |
43 | + } else if (option.equals("writer")) { | |
44 | + query = "select * from user where writer like ? order by no desc limit ?, 7"; | |
45 | + data = 2; | |
46 | + } | |
47 | + | |
48 | + try { | |
49 | + conn = Database.getConnection(); | |
50 | + if (data == 0) { | |
51 | + pstmt = conn.prepareStatement(query); | |
52 | + pstmt.setInt(1, pageStart); | |
53 | + } else { | |
54 | + pstmt = conn.prepareStatement(query); | |
55 | + | |
56 | + pstmt.setString(1, "%" + searchText + "%"); | |
57 | + pstmt.setInt(2, pageStart); | |
58 | + } | |
59 | + rs = pstmt.executeQuery(); | |
60 | + while (rs.next()) { | |
61 | + int no = rs.getInt("no"); | |
62 | + String writer = rs.getString("writer"); | |
63 | + String title = rs.getString("title"); | |
64 | + String contents = rs.getString("contents"); | |
65 | + String date = rs.getString("date"); | |
66 | + int view = rs.getInt("view"); | |
67 | + int listNum = rs.getInt("listNum"); | |
68 | + int depth = rs.getInt("depth"); | |
69 | + | |
70 | + MemberDTO dto = new MemberDTO(); | |
71 | + | |
72 | + dto.setNo(no); | |
73 | + dto.setWriter(writer); | |
74 | + dto.setTitle(title); | |
75 | + dto.setContents(contents); | |
76 | + dto.setDate(date); | |
77 | + dto.setView(view); | |
78 | + dto.setListNum(listNum); | |
79 | + dto.setDepth(depth); | |
80 | + | |
81 | + list.add(dto); | |
82 | + } | |
83 | + return list; | |
84 | + } catch (Exception e) { | |
85 | + e.printStackTrace(); | |
86 | + return null; | |
87 | + } finally { | |
88 | + try { | |
89 | + if (rs != null) { | |
90 | + rs.close(); | |
91 | + } | |
92 | + if (pstmt != null) { | |
93 | + pstmt.close(); | |
94 | + } | |
95 | + if (conn != null) { | |
96 | + conn.close(); | |
97 | + } | |
98 | + } catch (Exception e2) { | |
99 | + e2.printStackTrace(); | |
100 | + } | |
101 | + } | |
102 | + } | |
103 | + | |
104 | + public MemberDTO getMember(int no) { | |
105 | + conn = null; | |
106 | + pstmt = null; | |
107 | + rs = null; | |
108 | + | |
109 | + String query = "select * from user where no = ?"; | |
110 | + | |
111 | + try { | |
112 | + conn = Database.getConnection(); | |
113 | + pstmt = conn.prepareStatement(query); | |
114 | + pstmt.setInt(1, no); | |
115 | + rs = pstmt.executeQuery(); | |
116 | + rs.next(); | |
117 | + | |
118 | + MemberDTO member = new MemberDTO(); | |
119 | + member.setWriter(rs.getString("writer")); | |
120 | + member.setTitle(rs.getString("title")); | |
121 | + member.setContents(rs.getString("contents")); | |
122 | + member.setDate(rs.getString("date")); | |
123 | + member.setFile(rs.getString("file")); | |
124 | + member.setView(rs.getInt("view")); | |
125 | + | |
126 | + return member; | |
127 | + } catch (Exception e) { | |
128 | + e.printStackTrace(); | |
129 | + return null; | |
130 | + } finally { | |
131 | + try { | |
132 | + if (rs != null) { | |
133 | + rs.close(); | |
134 | + } | |
135 | + if (pstmt != null) { | |
136 | + pstmt.close(); | |
137 | + } | |
138 | + if (conn != null) { | |
139 | + conn.close(); | |
140 | + } | |
141 | + } catch (Exception e2) { | |
142 | + e2.printStackTrace(); | |
143 | + } | |
144 | + } | |
145 | + } | |
146 | + | |
147 | + public boolean setInsert(String writer, String title, String contents, int view, String inputDate) { | |
148 | + conn = null; | |
149 | + pstmt = null; | |
150 | + rs = null; | |
151 | + boolean result = false; | |
152 | + | |
153 | + String query = "insert into user values(?, ?, ?, ?, ?, ?, ?, ?, ?)"; | |
154 | + | |
155 | + try { | |
156 | + conn = Database.getConnection(); | |
157 | + pstmt = conn.prepareStatement(query); | |
158 | + pstmt.setString(1, null); | |
159 | + pstmt.setString(2, writer); | |
160 | + pstmt.setString(3, title); | |
161 | + pstmt.setString(4, contents); | |
162 | + pstmt.setString(5, inputDate); | |
163 | + pstmt.setInt(6, view); | |
164 | + pstmt.setString(7, null); | |
165 | + pstmt.setInt(8, 0); /*ÇØ´ç ±ÛÀÇ no¸¦ listNumÀ¸·Î ³Ö±â*/ | |
166 | + pstmt.setInt(9, 0); | |
167 | + pstmt.executeUpdate(); | |
168 | + | |
169 | + return true; | |
170 | + } catch (Exception e) { | |
171 | + e.printStackTrace(); | |
172 | + return false; | |
173 | + } finally { | |
174 | + try { | |
175 | + if (rs != null) { | |
176 | + rs.close(); | |
177 | + } | |
178 | + if (pstmt != null) { | |
179 | + pstmt.close(); | |
180 | + } | |
181 | + if (conn != null) { | |
182 | + conn.close(); | |
183 | + } | |
184 | + } catch (Exception e2) { | |
185 | + e2.printStackTrace(); | |
186 | + } | |
187 | + } | |
188 | + } | |
189 | + | |
190 | + public boolean setDelete(int no) { | |
191 | + conn = null; | |
192 | + pstmt = null; | |
193 | + rs = null; | |
194 | + boolean result = false; | |
195 | + | |
196 | + String query = "delete from user where no = ?"; | |
197 | + | |
198 | + try { | |
199 | + conn = Database.getConnection(); | |
200 | + pstmt = conn.prepareStatement(query); | |
201 | + pstmt.setInt(1, no); | |
202 | + pstmt.executeUpdate(); | |
203 | + | |
204 | + return true; | |
205 | + } catch (Exception e) { | |
206 | + e.printStackTrace(); | |
207 | + return false; | |
208 | + } finally { | |
209 | + try { | |
210 | + if (rs != null) { | |
211 | + rs.close(); | |
212 | + } | |
213 | + if (pstmt != null) { | |
214 | + pstmt.close(); | |
215 | + } | |
216 | + if (conn != null) { | |
217 | + conn.close(); | |
218 | + } | |
219 | + } catch (Exception e2) { | |
220 | + e2.printStackTrace(); | |
221 | + } | |
222 | + } | |
223 | + } | |
224 | + | |
225 | + public boolean setUpdate(int no, String writer, String title, String contents) { | |
226 | + conn = null; | |
227 | + pstmt = null; | |
228 | + rs = null; | |
229 | + boolean result = false; | |
230 | + | |
231 | + String query = "update user set title=?, writer=?, contents=? where no=?"; | |
232 | + | |
233 | + try { | |
234 | + conn = Database.getConnection(); | |
235 | + pstmt = conn.prepareStatement(query); | |
236 | + pstmt.setString(1, writer); | |
237 | + pstmt.setString(2, title); | |
238 | + pstmt.setString(3, contents); | |
239 | + pstmt.setInt(4, no); | |
240 | + pstmt.executeUpdate(); | |
241 | + | |
242 | + return true; | |
243 | + } catch (Exception e) { | |
244 | + e.printStackTrace(); | |
245 | + return false; | |
246 | + } finally { | |
247 | + try { | |
248 | + if (rs != null) { | |
249 | + rs.close(); | |
250 | + } | |
251 | + if (pstmt != null) { | |
252 | + pstmt.close(); | |
253 | + } | |
254 | + if (conn != null) { | |
255 | + conn.close(); | |
256 | + } | |
257 | + } catch (Exception e2) { | |
258 | + e2.printStackTrace(); | |
259 | + } | |
260 | + } | |
261 | + } | |
262 | + | |
263 | + public boolean setCountUpdate(int no, int view) { | |
264 | + conn = null; | |
265 | + pstmt = null; | |
266 | + rs = null; | |
267 | + boolean result = false; | |
268 | + | |
269 | + String query = "update user set view=? where no=?"; | |
270 | + | |
271 | + try { | |
272 | + conn = Database.getConnection(); | |
273 | + pstmt = conn.prepareStatement(query); | |
274 | + pstmt.setInt(1, view); | |
275 | + pstmt.setInt(2, no); | |
276 | + pstmt.executeUpdate(); | |
277 | + | |
278 | + return true; | |
279 | + } catch (Exception e) { | |
280 | + e.printStackTrace(); | |
281 | + return false; | |
282 | + } finally { | |
283 | + try { | |
284 | + if (rs != null) { | |
285 | + rs.close(); | |
286 | + } | |
287 | + if (pstmt != null) { | |
288 | + pstmt.close(); | |
289 | + } | |
290 | + if (conn != null) { | |
291 | + conn.close(); | |
292 | + } | |
293 | + } catch (Exception e2) { | |
294 | + e2.printStackTrace(); | |
295 | + } | |
296 | + } | |
297 | + } | |
298 | + | |
299 | + public int getCount() { | |
300 | + conn = null; | |
301 | + pstmt = null; | |
302 | + rs = null; | |
303 | + | |
304 | + int count = 0; | |
305 | + String sql = "select count(*) from user"; | |
306 | + try { | |
307 | + conn = Database.getConnection(); | |
308 | + pstmt = conn.prepareStatement(sql); | |
309 | + rs = pstmt.executeQuery(); | |
310 | + if (rs.next()) { | |
311 | + count = rs.getInt(1); | |
312 | + } | |
313 | + } catch (Exception e) { | |
314 | + e.printStackTrace(); | |
315 | + } finally { | |
316 | + try { | |
317 | + if (rs != null) { | |
318 | + rs.close(); | |
319 | + } | |
320 | + if (pstmt != null) { | |
321 | + pstmt.close(); | |
322 | + } | |
323 | + if (conn != null) { | |
324 | + conn.close(); | |
325 | + } | |
326 | + } catch (Exception e2) { | |
327 | + e2.printStackTrace(); | |
328 | + } | |
329 | + } | |
330 | + return count; | |
331 | + } | |
332 | + | |
333 | + public int getCountFor(String option, String searchText) { | |
334 | + conn = null; | |
335 | + pstmt = null; | |
336 | + rs = null; | |
337 | + | |
338 | + String query = ""; | |
339 | + int data = 0; | |
340 | + if (searchText == null) { | |
341 | + query = "select count(*) from user"; | |
342 | + data = 0; | |
343 | + } else if (option.equals("title")) { | |
344 | + query = "select count(*) from user where title like ?"; | |
345 | + data = 1; | |
346 | + } else if (option.equals("writer")) { | |
347 | + query = "select count(*) from user where writer like ?"; | |
348 | + data = 2; | |
349 | + } | |
350 | + | |
351 | + int count = 0; | |
352 | + try { | |
353 | + conn = Database.getConnection(); | |
354 | + if (data == 1) { | |
355 | + pstmt = conn.prepareStatement(query); | |
356 | + pstmt.setString(1, "%" + searchText + "%"); | |
357 | + } else if (data == 2) { | |
358 | + pstmt = conn.prepareStatement(query); | |
359 | + pstmt.setString(1, "%" + searchText + "%"); | |
360 | + } else { | |
361 | + pstmt = conn.prepareStatement(query); | |
362 | + } | |
363 | + rs = pstmt.executeQuery(); | |
364 | + if (rs.next()) { | |
365 | + count = rs.getInt(1); | |
366 | + } | |
367 | + } catch (Exception e) { | |
368 | + e.printStackTrace(); | |
369 | + } finally { | |
370 | + try { | |
371 | + if (rs != null) { | |
372 | + rs.close(); | |
373 | + } | |
374 | + if (pstmt != null) { | |
375 | + pstmt.close(); | |
376 | + } | |
377 | + if (conn != null) { | |
378 | + conn.close(); | |
379 | + } | |
380 | + } catch (Exception e2) { | |
381 | + e2.printStackTrace(); | |
382 | + } | |
383 | + } | |
384 | + return count; | |
385 | + } | |
386 | + | |
387 | + public boolean setReplyInsert(String repleyWriter, String repleyContent, int no, int password) { | |
388 | + conn = null; | |
389 | + pstmt = null; | |
390 | + rs = null; | |
391 | + boolean result = false; | |
392 | + | |
393 | + String query = "insert into reply values(?, ?, ?, ?, ?)"; | |
394 | + | |
395 | + try { | |
396 | + conn = Database.getConnection(); | |
397 | + pstmt = conn.prepareStatement(query); | |
398 | + pstmt.setString(1, null); | |
399 | + pstmt.setInt(2, no); | |
400 | + pstmt.setString(3, repleyWriter); | |
401 | + pstmt.setString(4, repleyContent); | |
402 | + pstmt.setInt(5, password); | |
403 | + pstmt.executeUpdate(); | |
404 | + | |
405 | + return true; | |
406 | + } catch (Exception e) { | |
407 | + e.printStackTrace(); | |
408 | + return false; | |
409 | + } finally { | |
410 | + try { | |
411 | + if (rs != null) { | |
412 | + rs.close(); | |
413 | + } | |
414 | + if (pstmt != null) { | |
415 | + pstmt.close(); | |
416 | + } | |
417 | + if (conn != null) { | |
418 | + conn.close(); | |
419 | + } | |
420 | + } catch (Exception e2) { | |
421 | + e2.printStackTrace(); | |
422 | + } | |
423 | + } | |
424 | + } | |
425 | + | |
426 | + public List<ReplyDTO> ReplyList(int no) { | |
427 | + List<ReplyDTO> list2 = new ArrayList<ReplyDTO>(); | |
428 | + | |
429 | + conn = null; | |
430 | + pstmt = null; | |
431 | + rs = null; | |
432 | + | |
433 | + String query = "select * from reply where col_num=?"; | |
434 | + | |
435 | + try { | |
436 | + conn = Database.getConnection(); | |
437 | + pstmt = conn.prepareStatement(query); | |
438 | + pstmt.setInt(1, no); | |
439 | + rs = pstmt.executeQuery(); | |
440 | + | |
441 | + while (rs.next()) { | |
442 | + int no1 = rs.getInt("num"); | |
443 | + int colNo = rs.getInt("col_num"); | |
444 | + String replyWriter = rs.getString("reply_writer"); | |
445 | + String replyContent = rs.getString("reply_content"); | |
446 | + | |
447 | + ReplyDTO dto = new ReplyDTO(); | |
448 | + | |
449 | + dto.setNo(no1); | |
450 | + dto.setColNo(colNo); | |
451 | + dto.setReplyWriter(replyWriter); | |
452 | + dto.setReplyContent(replyContent); | |
453 | + | |
454 | + list2.add(dto); | |
455 | + } | |
456 | + | |
457 | + return list2; | |
458 | + } catch (Exception e) { | |
459 | + e.printStackTrace(); | |
460 | + return null; | |
461 | + } finally { | |
462 | + try { | |
463 | + if (rs != null) { | |
464 | + rs.close(); | |
465 | + } | |
466 | + if (pstmt != null) { | |
467 | + pstmt.close(); | |
468 | + } | |
469 | + if (conn != null) { | |
470 | + conn.close(); | |
471 | + } | |
472 | + } catch (Exception e2) { | |
473 | + e2.printStackTrace(); | |
474 | + } | |
475 | + } | |
476 | + } | |
477 | + | |
478 | + public boolean setUpdateReply(int no, String changedRepltWriter, String changedReplyContent) { | |
479 | + conn = null; | |
480 | + pstmt = null; | |
481 | + rs = null; | |
482 | + boolean result = false; | |
483 | + | |
484 | + String query = "update reply set reply_writer=?, reply_content=? where num=?"; | |
485 | + | |
486 | + try { | |
487 | + conn = Database.getConnection(); | |
488 | + pstmt = conn.prepareStatement(query); | |
489 | + pstmt.setString(1, changedRepltWriter); | |
490 | + pstmt.setString(2, changedReplyContent); | |
491 | + pstmt.setInt(3, no); | |
492 | + pstmt.executeUpdate(); | |
493 | + | |
494 | + return true; | |
495 | + } catch (Exception e) { | |
496 | + e.printStackTrace(); | |
497 | + return false; | |
498 | + } finally { | |
499 | + try { | |
500 | + if (rs != null) { | |
501 | + rs.close(); | |
502 | + } | |
503 | + if (pstmt != null) { | |
504 | + pstmt.close(); | |
505 | + } | |
506 | + if (conn != null) { | |
507 | + conn.close(); | |
508 | + } | |
509 | + } catch (Exception e2) { | |
510 | + e2.printStackTrace(); | |
511 | + } | |
512 | + } | |
513 | + } | |
514 | + | |
515 | + public boolean setReplyDelete(int no) { | |
516 | + conn = null; | |
517 | + pstmt = null; | |
518 | + rs = null; | |
519 | + boolean result = false; | |
520 | + | |
521 | + String query = "delete from reply where num = ?"; | |
522 | + | |
523 | + try { | |
524 | + conn = Database.getConnection(); | |
525 | + pstmt = conn.prepareStatement(query); | |
526 | + pstmt.setInt(1, no); | |
527 | + pstmt.executeUpdate(); | |
528 | + | |
529 | + return true; | |
530 | + } catch (Exception e) { | |
531 | + e.printStackTrace(); | |
532 | + return false; | |
533 | + } finally { | |
534 | + try { | |
535 | + if (rs != null) { | |
536 | + rs.close(); | |
537 | + } | |
538 | + if (pstmt != null) { | |
539 | + pstmt.close(); | |
540 | + } | |
541 | + if (conn != null) { | |
542 | + conn.close(); | |
543 | + } | |
544 | + } catch (Exception e2) { | |
545 | + e2.printStackTrace(); | |
546 | + } | |
547 | + } | |
548 | + } | |
549 | + | |
550 | + public int getPassword(int no) { | |
551 | + conn = null; | |
552 | + pstmt = null; | |
553 | + rs = null; | |
554 | + int password = 0; | |
555 | + | |
556 | + String query = "select pw from reply where num = ?"; | |
557 | + try { | |
558 | + conn = Database.getConnection(); | |
559 | + pstmt = conn.prepareStatement(query); | |
560 | + pstmt.setInt(1, no); | |
561 | + rs = pstmt.executeQuery(); | |
562 | + if (rs.next()) { | |
563 | + password = rs.getInt(1); | |
564 | + } | |
565 | + } catch (Exception e) { | |
566 | + e.printStackTrace(); | |
567 | + } finally { | |
568 | + try { | |
569 | + if (rs != null) { | |
570 | + rs.close(); | |
571 | + } | |
572 | + if (pstmt != null) { | |
573 | + pstmt.close(); | |
574 | + } | |
575 | + if (conn != null) { | |
576 | + conn.close(); | |
577 | + } | |
578 | + } catch (Exception e2) { | |
579 | + e2.printStackTrace(); | |
580 | + } | |
581 | + } | |
582 | + return password; | |
583 | + } | |
584 | + | |
585 | + public boolean setAnswerInsert(String answerWriter, String answerTitle, String answerContent, int motherNo, String inputDate) { | |
586 | + conn = null; | |
587 | + pstmt = null; | |
588 | + rs = null; | |
589 | + rs2 = null; | |
590 | + boolean result = false; | |
591 | + | |
592 | + String query = "insert into user values(?, ?, ?, ?, ?, ?, ?, ?, ?)"; //insert | |
593 | + String query2 = "select depth from user where no = ?"; //depth check | |
594 | + String query3 = "update user set listNum=? where no=? and depth=?"; //root content listNum update | |
595 | + String query4 = "select listNum from user where no = ?"; | |
596 | + String query5 = "select listNum from user where depth=? and listNum=?"; | |
597 | + try { | |
598 | + int motherDepth = 0; | |
599 | + int motherListNum = 0; | |
600 | + int motherRootListNum = 0; | |
601 | + conn = Database.getConnection(); | |
602 | + | |
603 | + pstmt4 = conn.prepareStatement(query4); | |
604 | + pstmt4.setInt(1, motherNo); | |
605 | + rs4 = pstmt4.executeQuery(); | |
606 | + if(rs4.next()) { | |
607 | + motherListNum = rs4.getInt(1); | |
608 | + } | |
609 | + | |
610 | +/*******************************************************************************************/ | |
611 | + pstmt5 = conn.prepareStatement(query5); | |
612 | + pstmt5.setInt(1, 0); | |
613 | + pstmt5.setInt(2, motherListNum); | |
614 | + rs5 = pstmt5.executeQuery(); | |
615 | + if(rs5.next()) { | |
616 | + motherRootListNum = rs5.getInt(1); | |
617 | + } | |
618 | + | |
619 | +/*******************************************************************************************/ | |
620 | + pstmt3 = conn.prepareStatement(query3); | |
621 | + pstmt3.setInt(1, motherNo); | |
622 | + pstmt3.setInt(2, motherNo); | |
623 | + pstmt3.setInt(3, 0); | |
624 | + pstmt3.executeUpdate(); | |
625 | +/*******************************************************************************************/ | |
626 | + pstmt2 = conn.prepareStatement(query2); | |
627 | + pstmt2.setInt(1, motherNo); | |
628 | + rs2 = pstmt2.executeQuery(); | |
629 | + if (rs2.next()) { | |
630 | + motherDepth = rs2.getInt(1); | |
631 | + } | |
632 | +/*************************************************************************************************/ | |
633 | + pstmt = conn.prepareStatement(query); | |
634 | + pstmt.setString(1, null); | |
635 | + pstmt.setString(2, answerWriter); | |
636 | + pstmt.setString(3, answerTitle); | |
637 | + pstmt.setString(4, answerContent); | |
638 | + pstmt.setString(5, inputDate); | |
639 | + pstmt.setInt(6, 1); //view | |
640 | + pstmt.setString(7, null); //file | |
641 | + | |
642 | + if(motherDepth == 0) { /*ù ´ä±ÛÀ϶§*/ | |
643 | + pstmt.setInt(8, motherNo); | |
644 | + }else { | |
645 | + pstmt.setInt(8, motherRootListNum); /*ÀÌÁß ´ä±ÛÀ϶§*/ | |
646 | + } | |
647 | + pstmt.setInt(9, motherDepth + 1); /* ºÎ¸ð±Û depthÀÇ +1 */ | |
648 | + pstmt.executeUpdate(); | |
649 | + | |
650 | + return true; | |
651 | + } catch (Exception e) { | |
652 | + e.printStackTrace(); | |
653 | + return false; | |
654 | + } finally { | |
655 | + try { | |
656 | + if (rs != null) { | |
657 | + rs.close(); | |
658 | + } | |
659 | + if (pstmt != null) { | |
660 | + pstmt.close(); | |
661 | + } | |
662 | + if (conn != null) { | |
663 | + conn.close(); | |
664 | + } | |
665 | + } catch (Exception e2) { | |
666 | + e2.printStackTrace(); | |
667 | + } | |
668 | + } | |
669 | + } | |
670 | + | |
671 | +} |
+++ src/main/java/model/MemberDTO.java
... | ... | @@ -0,0 +1,92 @@ |
1 | +package model; | |
2 | + | |
3 | +public class MemberDTO { | |
4 | + | |
5 | + private int no; | |
6 | + private String writer; | |
7 | + private String title; | |
8 | + private String contents; | |
9 | + private String date; | |
10 | + private String file; | |
11 | + private int view; | |
12 | + private int listNum; | |
13 | + private int depth; | |
14 | + | |
15 | + public int getListNum() { | |
16 | + return listNum; | |
17 | + } | |
18 | + | |
19 | + public void setListNum(int listNum) { | |
20 | + this.listNum = listNum; | |
21 | + } | |
22 | + | |
23 | + public int getDepth() { | |
24 | + return depth; | |
25 | + } | |
26 | + | |
27 | + public void setDepth(int depth) { | |
28 | + this.depth = depth; | |
29 | + } | |
30 | + | |
31 | + public String getFile() { | |
32 | + return this.file; | |
33 | + } | |
34 | + | |
35 | + public void setFile(String file) { | |
36 | + this.file = file; | |
37 | + } | |
38 | + | |
39 | + public String getDate() { | |
40 | + return this.date; | |
41 | + } | |
42 | + | |
43 | + public void setDate(String date) { | |
44 | + this.date = date; | |
45 | + } | |
46 | + | |
47 | + public int getView() { | |
48 | + return this.view; | |
49 | + } | |
50 | + | |
51 | + public void setView(int view) { | |
52 | + this.view = view; | |
53 | + } | |
54 | + | |
55 | +// public String toString() { | |
56 | +// return "MemberDTO [no=" + this.no + ", writer=" + this.writer + ", title=" + this.title + ", contents=" | |
57 | +// + this.contents + ", view=" + this.view + "]\n"; | |
58 | +// } | |
59 | + | |
60 | + public int getNo() { | |
61 | + return this.no; | |
62 | + } | |
63 | + | |
64 | + public void setNo(int no) { | |
65 | + this.no = no; | |
66 | + } | |
67 | + | |
68 | + public String getWriter() { | |
69 | + return this.writer; | |
70 | + } | |
71 | + | |
72 | + public void setWriter(String writer) { | |
73 | + this.writer = writer; | |
74 | + } | |
75 | + | |
76 | + public String getTitle() { | |
77 | + return this.title; | |
78 | + } | |
79 | + | |
80 | + public void setTitle(String title) { | |
81 | + this.title = title; | |
82 | + } | |
83 | + | |
84 | + public String getContents() { | |
85 | + return this.contents; | |
86 | + } | |
87 | + | |
88 | + public void setContents(String contents) { | |
89 | + this.contents = contents; | |
90 | + } | |
91 | + | |
92 | +} |
+++ src/main/java/model/ReplyDTO.java
... | ... | @@ -0,0 +1,33 @@ |
1 | +package model; | |
2 | + | |
3 | +public class ReplyDTO { | |
4 | + | |
5 | + private int no; | |
6 | + private int colNo; | |
7 | + private String replyWriter; | |
8 | + private String replyContent; | |
9 | + | |
10 | + public int getNo() { return this.no; } | |
11 | + | |
12 | + | |
13 | + public void setNo(int no) { this.no = no; } | |
14 | + | |
15 | + | |
16 | + public int getColNo() { return this.colNo; } | |
17 | + | |
18 | + | |
19 | + public void setColNo(int colNo) { this.colNo = colNo; } | |
20 | + | |
21 | + | |
22 | + public String getReplyWriter() { return this.replyWriter; } | |
23 | + | |
24 | + | |
25 | + public void setReplyWriter(String replyWriter) { this.replyWriter = replyWriter; } | |
26 | + | |
27 | + | |
28 | + public String getReplyContent() { return this.replyContent; } | |
29 | + | |
30 | + | |
31 | + public void setReplyContent(String replyContent) { this.replyContent = replyContent; } | |
32 | + | |
33 | +} |
+++ src/main/webapp/META-INF/MANIFEST.MF
... | ... | @@ -0,0 +1,3 @@ |
1 | +Manifest-Version: 1.0 | |
2 | +Class-Path: | |
3 | + |
+++ src/main/webapp/WEB-INF/lib/cos-05Nov2002.jar
Binary file is not shown |
+++ src/main/webapp/WEB-INF/lib/cos.jar
Binary file is not shown |
+++ src/main/webapp/WEB-INF/lib/jstl-1.2.jar
Binary file is not shown |
+++ src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.49.jar
Binary file is not shown |
+++ src/main/webapp/WEB-INF/lib/mysql-connector-java-8.0.26.jar
Binary file is not shown |
+++ src/main/webapp/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar
Binary file is not shown |
+++ src/main/webapp/WEB-INF/web.xml
... | ... | @@ -0,0 +1,112 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> | |
3 | + <display-name>WebTest</display-name> | |
4 | + <display-name>Apache-Axis</display-name> | |
5 | + <servlet> | |
6 | + <display-name>Apache-Axis Servlet</display-name> | |
7 | + <servlet-name>AxisServlet</servlet-name> | |
8 | + <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class> | |
9 | + </servlet> | |
10 | + <servlet> | |
11 | + <display-name>Axis Admin Servlet</display-name> | |
12 | + <servlet-name>AdminServlet</servlet-name> | |
13 | + <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class> | |
14 | + <load-on-startup>100</load-on-startup> | |
15 | + </servlet> | |
16 | + <servlet> | |
17 | + <display-name>SOAPMonitorService</display-name> | |
18 | + <servlet-name>SOAPMonitorService</servlet-name> | |
19 | + <servlet-class>org.apache.axis.monitor.SOAPMonitorService</servlet-class> | |
20 | + <init-param> | |
21 | + <param-name>SOAPMonitorPort</param-name> | |
22 | + <param-value>5101</param-value> | |
23 | + </init-param> | |
24 | + <load-on-startup>100</load-on-startup> | |
25 | + </servlet> | |
26 | + <servlet> | |
27 | + <servlet-name>FileTestServlet</servlet-name> | |
28 | + <servlet-class>com.FileTest.FileTestServlet</servlet-class> | |
29 | + </servlet> | |
30 | + <servlet-mapping> | |
31 | + <servlet-name>FileTestServlet</servlet-name> | |
32 | + <url-pattern>/file/*</url-pattern> | |
33 | + </servlet-mapping> | |
34 | + <servlet-mapping> | |
35 | + <servlet-name>AxisServlet</servlet-name> | |
36 | + <url-pattern>/servlet/AxisServlet</url-pattern> | |
37 | + </servlet-mapping> | |
38 | + <servlet-mapping> | |
39 | + <servlet-name>AxisServlet</servlet-name> | |
40 | + <url-pattern>*.jws</url-pattern> | |
41 | + </servlet-mapping> | |
42 | + <servlet-mapping> | |
43 | + <servlet-name>AxisServlet</servlet-name> | |
44 | + <url-pattern>/services/*</url-pattern> | |
45 | + </servlet-mapping> | |
46 | + <servlet-mapping> | |
47 | + <servlet-name>SOAPMonitorService</servlet-name> | |
48 | + <url-pattern>/SOAPMonitor</url-pattern> | |
49 | + </servlet-mapping> | |
50 | + <servlet-mapping> | |
51 | + <servlet-name>AdminServlet</servlet-name> | |
52 | + <url-pattern>/servlet/AdminServlet</url-pattern> | |
53 | + </servlet-mapping> | |
54 | + <mime-mapping> | |
55 | + <extension>wsdl</extension> | |
56 | + <mime-type>text/xml</mime-type> | |
57 | + </mime-mapping> | |
58 | + <welcome-file-list> | |
59 | + <welcome-file>index.html</welcome-file> | |
60 | + <welcome-file>index.htm</welcome-file> | |
61 | + <welcome-file>index.jsp</welcome-file> | |
62 | + <welcome-file>default.html</welcome-file> | |
63 | + <welcome-file>default.htm</welcome-file> | |
64 | + <welcome-file>default.jsp</welcome-file> | |
65 | + </welcome-file-list> | |
66 | + <context-param> | |
67 | + <param-name>global</param-name> | |
68 | + <param-value>My WebSite</param-value> | |
69 | + </context-param> | |
70 | + <servlet> | |
71 | + <servlet-name>main</servlet-name> | |
72 | + <servlet-class>servlet.Main</servlet-class> | |
73 | + <init-param> | |
74 | + <param-name>title</param-name> | |
75 | + <param-value>Main Page</param-value> | |
76 | + </init-param> | |
77 | + </servlet> | |
78 | + | |
79 | + <servlet> | |
80 | + <servlet-name>testpage</servlet-name> | |
81 | + <jsp-file>/test.jsp</jsp-file> | |
82 | + <init-param> | |
83 | + <param-name>name</param-name> | |
84 | + <param-value>홍길동</param-value> | |
85 | + </init-param> | |
86 | + <init-param> | |
87 | + <param-name>age</param-name> | |
88 | + <param-value>10</param-value> | |
89 | + </init-param> | |
90 | + </servlet> | |
91 | + | |
92 | + <servlet> | |
93 | + <servlet-name>testpage2</servlet-name> | |
94 | + <jsp-file>/test2.jsp</jsp-file> | |
95 | + </servlet> | |
96 | + | |
97 | + <servlet-mapping> | |
98 | + <servlet-name>main</servlet-name> | |
99 | + <url-pattern>/main</url-pattern> | |
100 | + </servlet-mapping> | |
101 | + | |
102 | + <servlet-mapping> | |
103 | + <servlet-name>testpage</servlet-name> | |
104 | + <url-pattern>/test</url-pattern> | |
105 | + </servlet-mapping> | |
106 | + | |
107 | + <servlet-mapping> | |
108 | + <servlet-name>testpage2</servlet-name> | |
109 | + <url-pattern>/test2</url-pattern> | |
110 | + </servlet-mapping> | |
111 | + | |
112 | +</web-app> |
+++ src/main/webapp/view/answerWriteFront.jsp
... | ... | @@ -0,0 +1,45 @@ |
1 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
2 | + pageEncoding="UTF-8"%> | |
3 | +<!DOCTYPE html> | |
4 | +<html lang="ko"> | |
5 | +<head> | |
6 | +<meta charset="UTF-8"> | |
7 | +<title>Insert title here</title> | |
8 | +<style> | |
9 | +#page { | |
10 | + background-color: antiquewhite; | |
11 | + width: 80%; | |
12 | + margin: 0 auto; | |
13 | + text-align: center; | |
14 | + height: 430px; | |
15 | +} | |
16 | +#inputContent{ | |
17 | + width: 80%; | |
18 | + height: 200px; | |
19 | +} | |
20 | +#submit{ | |
21 | + float: right; | |
22 | +} | |
23 | +#bottomSector{ | |
24 | + width: 100%; | |
25 | +} | |
26 | +#btn{ | |
27 | + float: right; | |
28 | +} | |
29 | +</style> | |
30 | +</head> | |
31 | +<body> | |
32 | + <div id="page"> | |
33 | + <h1>This is answerWrite Page</h1> | |
34 | + <hr /> | |
35 | + <%int motherNo = Integer.parseInt(request.getParameter("motherNo")); %> | |
36 | + <form action="answerWriteBack?motherNo=<%=motherNo %>" method="post" id="form" > | |
37 | + 작성자 : <input type="text" name="answerWriter"><br /> | |
38 | + 제목 : <input type="text" name="answerTitle"><br /> | |
39 | + 내용 : <textarea id="inputContent" name="answerContents"></textarea><br /> | |
40 | + <input id="submit" type="submit" value="등록"> | |
41 | + </form> | |
42 | + <div id="bottomSector"><button id="btn" onclick="location.href='list.do'">목록</button></div> | |
43 | + </div> | |
44 | +</body> | |
45 | +</html>(No newline at end of file) |
+++ src/main/webapp/view/content.jsp
... | ... | @@ -0,0 +1,169 @@ |
1 | +<%@page import="model.ReplyDTO"%> | |
2 | +<%@page import="java.util.List"%> | |
3 | +<%@page import="java.util.Map"%> | |
4 | +<%@page import="model.MemberDTO"%> | |
5 | +<%@page import="model.MemberDAO"%> | |
6 | +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | |
7 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
8 | + pageEncoding="UTF-8"%> | |
9 | +<% | |
10 | +int no = Integer.parseInt(request.getParameter("no")); | |
11 | +MemberDAO dao = new MemberDAO(); | |
12 | +MemberDTO member = new MemberDTO(); | |
13 | +member = dao.getMember(no); | |
14 | +%> | |
15 | +<!DOCTYPE html> | |
16 | +<html lang="ko"> | |
17 | +<head> | |
18 | +<meta charset="UTF-8"> | |
19 | +<title>Insert title here</title> | |
20 | +<style> | |
21 | +#page { | |
22 | + background-color: antiquewhite; | |
23 | + width: 80%; | |
24 | + margin: 0 auto; | |
25 | +} | |
26 | + | |
27 | +#top { | |
28 | + text-align: center; | |
29 | +} | |
30 | + | |
31 | +#middle { | |
32 | + text-align: right; | |
33 | +} | |
34 | + | |
35 | +#mainContents { | |
36 | + background-color: white; | |
37 | + width: 95%; | |
38 | + height: 300px; | |
39 | + border: 1px black solid; | |
40 | + margin-left: 25px; | |
41 | +} | |
42 | + | |
43 | +#innerContents { | |
44 | + margin-left: 30px; | |
45 | +} | |
46 | + | |
47 | +#crudButton { | |
48 | + text-align: right; | |
49 | + margin-right: 25px; | |
50 | +} | |
51 | +#replySector { | |
52 | + width: 100%; | |
53 | + border-top: 10px solid white; | |
54 | +} | |
55 | + | |
56 | +#replyForm{ | |
57 | + width: 55%; | |
58 | +} | |
59 | + | |
60 | +#replySubmit{ | |
61 | + text-align: right; | |
62 | +} | |
63 | + | |
64 | +#repleyPrintSector{ | |
65 | + width: 100%; | |
66 | + border-top: 10px solid white; | |
67 | +} | |
68 | + | |
69 | +#replyTitle{ | |
70 | + width: 100%; | |
71 | + text-align: center; | |
72 | + border-bottom: 1px solid white; | |
73 | +} | |
74 | + | |
75 | +#replyArea{ | |
76 | + text-align:center; | |
77 | + width: 100%; | |
78 | + border-bottom: 3px solid white; | |
79 | +} | |
80 | + | |
81 | +#replyWriter{ | |
82 | + width: 22%; | |
83 | + text-align: center; | |
84 | +} | |
85 | + | |
86 | +#replyBtns{ | |
87 | + width: 100%; | |
88 | + text-align: center;} | |
89 | +</style> | |
90 | +</head> | |
91 | + <% | |
92 | + Map<String, Object> map = (Map<String, Object>) request.getAttribute("map"); | |
93 | + List<ReplyDTO> list = (List<ReplyDTO>) map.get("list2"); | |
94 | + int count = (int) map.get("count"); | |
95 | + %> | |
96 | +<body> | |
97 | + <div id="page"> | |
98 | + <div id="top"> | |
99 | + <h1> | |
100 | + 제목 : | |
101 | + <%=member.getTitle()%><br /> | |
102 | + </h1> | |
103 | + </div> | |
104 | + <hr /> | |
105 | + <div id="middle"> | |
106 | + <em>번호</em> : <strong><%=no%></strong> | |
107 | + <em>작성자</em> : <strong><%=member.getWriter()%></strong> | |
108 | + <em>작성일</em> : <strong><%=member.getDate()%></strong> | |
109 | + <em>조회수</em> : <strong><%=member.getView()%></strong> | |
110 | + </div> | |
111 | + <br /> | |
112 | + <div id="mainContents"> | |
113 | + <p id="innerContents"> | |
114 | + <%=member.getContents()%> | |
115 | + </p> | |
116 | + </div> | |
117 | + <br> | |
118 | + <% | |
119 | + if(member.getFile() == null){ | |
120 | + out.println("첨부파일 : <em>첨부된 파일이 없습니다.</em>"); | |
121 | + }else{%> | |
122 | + 첨부파일 : <a href="download.do?file=<%=member.getFile() %>"><%=member.getFile() %></a> | |
123 | + <%} | |
124 | + | |
125 | + %> | |
126 | + <div id="crudButton"> | |
127 | + <br /> | |
128 | + <button onClick="location.href='update.do?no=<%=no%>'">수정</button> | |
129 | + <button onClick="location.href='delete.do?no=<%=no%>'">삭제</button> | |
130 | + <button onClick="location.href='list.do'">목록</button> | |
131 | + <button onClick="location.href='answerWriteFront.do?motherNo=<%=no%>'">답글</button> | |
132 | + </div> | |
133 | + <div id="replySector"> | |
134 | + <form action="replyInsert.do?no=<%=no %>" id="replyForm" method="post"> | |
135 | + 작성자 : <input type="text" name="replyWriter"><br /><br /> | |
136 | + 댓글 : <textarea name="replyContent" id="" cols="80" rows="10"></textarea> <br /><br /> | |
137 | + 비밀번호 : <input type="password" name="password"> | |
138 | + 비밀번호 확인 : <input type="password" name="passwordCheck"> | |
139 | + <div id="replySubmit"> | |
140 | + <input type="submit" value="등록"> | |
141 | + </div> | |
142 | + </form> | |
143 | + </div> | |
144 | + <div id="repleyPrintSector"> | |
145 | + <div id="replyTitle"><h2>댓글</h2></div> | |
146 | + <%for(ReplyDTO rd : list) { %> | |
147 | + <div id="replyArea"> | |
148 | + <form method="post"> | |
149 | + <div id="replyWriter">작성자 : <input type="text" value="<%=rd.getReplyWriter() %>" name="changedReplyWriter"><br /> <br /></div> | |
150 | + 댓글 : <textarea cols="160" name="changedReplyContent"><%=rd.getReplyContent() %></textarea><br /><br /><br /> | |
151 | + <div id="replyWriter">비밀번호 : <input type="password" name="inputPassword"></div> | |
152 | + <div id="replyBtns"> | |
153 | + <input type="submit" formaction="replyUpdate.do?no=<%=rd.getNo() %>&upNo=<%=no %>" value="수정"> | |
154 | + <input type="submit" formaction="replyDelete.do?no=<%=rd.getNo() %>&upNo=<%=no %>" value="삭제"> | |
155 | + </div> | |
156 | + </form> | |
157 | + </div> | |
158 | + <%} %> | |
159 | + </div> | |
160 | + </div> | |
161 | +</body> | |
162 | +</html> | |
163 | + | |
164 | + | |
165 | + | |
166 | + | |
167 | + | |
168 | + | |
169 | + |
+++ src/main/webapp/view/list.jsp
... | ... | @@ -0,0 +1,334 @@ |
1 | +<%@page import="model.MemberDAO"%> | |
2 | +<%@page import="model.MemberDTO"%> | |
3 | +<%@page import="java.util.List"%> | |
4 | +<%@page import="java.util.Map"%> | |
5 | +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | |
6 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
7 | + pageEncoding="UTF-8"%> | |
8 | +<!DOCTYPE html> | |
9 | +<html lang="ko"> | |
10 | +<head> | |
11 | +<meta charset="UTF-8"> | |
12 | +<title>Insert title here</title> | |
13 | +<style> | |
14 | +#page { | |
15 | + background-color: antiquewhite; | |
16 | + width: 80%; | |
17 | + height: auto; | |
18 | + margin: 0 auto; | |
19 | + text-align: center; | |
20 | + margin: 0 auto; | |
21 | +} | |
22 | + | |
23 | +#title { | |
24 | + text-decoration: none; | |
25 | + color: black; | |
26 | +} | |
27 | + | |
28 | +#title:hover { | |
29 | + background-color: tomato; | |
30 | +} | |
31 | + | |
32 | +#table { | |
33 | + text-align: center; | |
34 | + width: 100%; | |
35 | + height: 400px; | |
36 | + border-collapse: collapse; | |
37 | + border-bottom: white; | |
38 | + border-style : 1px solid white; | |
39 | + border-right: none; | |
40 | + border-left: none; | |
41 | +} | |
42 | + | |
43 | +th { | |
44 | + border-top: midnightblue solid; | |
45 | + border-bottom: midnightblue solid; | |
46 | + background-color: cadetblue; | |
47 | +} | |
48 | + | |
49 | +td{ | |
50 | + font-size: 15px; | |
51 | +} | |
52 | + | |
53 | +#pageNumber { | |
54 | + text-align: right; | |
55 | +} | |
56 | + | |
57 | +#titleAnker { | |
58 | + text-decoration: none; | |
59 | + color: black; | |
60 | +} | |
61 | + | |
62 | +#titleAnker:hover { | |
63 | + color: red; | |
64 | +} | |
65 | + | |
66 | +#topSector { | |
67 | + width: 100%; | |
68 | +} | |
69 | + | |
70 | +#count { | |
71 | + display: inline-block; | |
72 | + float: left; | |
73 | +} | |
74 | + | |
75 | +#search { | |
76 | + float: right; | |
77 | +} | |
78 | + | |
79 | +#btn { | |
80 | + float: right; | |
81 | + border: 1px solid black; | |
82 | +} | |
83 | + | |
84 | +#btn:hover { | |
85 | + background-color: black; | |
86 | + color: white; | |
87 | +} | |
88 | + | |
89 | +#searchBtn { | |
90 | + border: 1px solid black; | |
91 | +} | |
92 | + | |
93 | +#searchBtn:hover { | |
94 | + background-color: black; | |
95 | + color: white; | |
96 | +} | |
97 | + | |
98 | +#pageNumberSector>a { | |
99 | + text-decoration: none; | |
100 | +} | |
101 | + | |
102 | +#h2 { | |
103 | + display: inline-block; | |
104 | +} | |
105 | + | |
106 | +#pagingBtn { | |
107 | + text-decoration: none; | |
108 | + color: black; | |
109 | +} | |
110 | + | |
111 | +#pagingBtn:hover { | |
112 | + background-color: black; | |
113 | + color: white; | |
114 | +} | |
115 | + | |
116 | +#bottomSector { | |
117 | + width: 100%; | |
118 | +} | |
119 | +</style> | |
120 | +</head> | |
121 | +<body> | |
122 | + <% | |
123 | + Map<String, Object> map = (Map<String, Object>) request.getAttribute("map"); | |
124 | + List<MemberDTO> list = (List<MemberDTO>) map.get("list"); | |
125 | + int count = (int) map.get("count"); | |
126 | + %> | |
127 | + | |
128 | + <div id="page"> | |
129 | + <a id="titleAnker" href="list.do"><h1> | |
130 | + <em>JSP_Notice Board</em> | |
131 | + </h1></a> | |
132 | + <div id="topSector"> | |
133 | + <span id="count">전체<%=count%>건 | |
134 | + </span> | |
135 | + <form id="search" action="list.do" method="get"> | |
136 | + <select name="option"> | |
137 | + <option name="title" value="title">제목</option> | |
138 | + <option name="writer" value="writer">작성자</option> | |
139 | + </select> <input type="text" name="searchText"> <input id="searchBtn" | |
140 | + type="submit" value="검색"> | |
141 | + </form> | |
142 | + <br> <br> | |
143 | + </div> | |
144 | + <table id="table" border="1" width="100%" height="400"> | |
145 | + <thead> | |
146 | + <tr> | |
147 | + <th>번호</th> | |
148 | + <th>제목</th> | |
149 | + <th>작성자</th> | |
150 | + <th>날짜</th> | |
151 | + <th>조회수</th> | |
152 | + </tr> | |
153 | + </thead> | |
154 | + <% | |
155 | + for (MemberDTO mb : list) { | |
156 | + %> | |
157 | + <tbody> | |
158 | + <tr> | |
159 | + <td> | |
160 | + <% | |
161 | + if(mb.getDepth() != 0){ | |
162 | + | |
163 | + }else{ | |
164 | + out.println(mb.getNo()); | |
165 | + } | |
166 | + | |
167 | + %> | |
168 | + </td> | |
169 | + <td> | |
170 | + <% | |
171 | + if(mb.getDepth() > 0){ | |
172 | + out.println("<img height=1 width='" + mb.getDepth()*20 + "'>└> RE:"); | |
173 | + }else{ | |
174 | + | |
175 | + } | |
176 | + %> | |
177 | + <a id="title" href="content.do?no=<%=mb.getNo()%>&view=<%=mb.getView() + 1%>"><strong><%=mb.getTitle()%></strong></a> | |
178 | + </td> | |
179 | + <td> | |
180 | + <% | |
181 | + if (mb.getWriter().equals("Anonymous")) { | |
182 | + out.println("<em>" + mb.getWriter() + "</em>"); | |
183 | + } else { | |
184 | + out.println(mb.getWriter()); | |
185 | + } | |
186 | + %> | |
187 | + </td> | |
188 | + <td><%=mb.getDate()%></td> | |
189 | + <td><%=mb.getView()%></td> | |
190 | + </tr> | |
191 | + </tbody> | |
192 | + <% | |
193 | + } | |
194 | + %> | |
195 | + </table> | |
196 | + <br /> | |
197 | + <div id="pageNumberSector"> | |
198 | + <% | |
199 | + MemberDAO dao = new MemberDAO(); | |
200 | + String searchText = request.getParameter("searchText"); | |
201 | + String option = request.getParameter("option"); | |
202 | + int allCount = dao.getCountFor(option, searchText); | |
203 | + | |
204 | + int list2 = 7; | |
205 | + String nowPage = request.getParameter("page"); | |
206 | + int currentPage; | |
207 | + if (nowPage != null) { | |
208 | + currentPage = Integer.parseInt(nowPage); | |
209 | + } else { | |
210 | + currentPage = 1; | |
211 | + } | |
212 | + int blockCnt = 3; | |
213 | + | |
214 | + double blockNum1 = Math.ceil((double) currentPage / (double) blockCnt); | |
215 | + int blockNum = (int) blockNum1; | |
216 | + int blockStart = ((blockNum - 1) * blockCnt) + 1; | |
217 | + int blockEnd = blockStart + blockCnt - 1; | |
218 | + int pageStart = (currentPage - 1) * list2; | |
219 | + double totalPage1 = Math.ceil((double) allCount / (double) list2); | |
220 | + int totalPage = (int) totalPage1; | |
221 | + if (blockEnd > totalPage) { | |
222 | + blockEnd = totalPage; | |
223 | + } | |
224 | + | |
225 | + if (allCount > 7) { | |
226 | + | |
227 | + if (currentPage > 1) { | |
228 | + if (request.getParameter("searchText") == null) { | |
229 | + %> | |
230 | + <a href='list.do?page=1&pageStart=0'>처음...</a> | |
231 | + <% | |
232 | + } else { | |
233 | + %> | |
234 | + <a | |
235 | + href='list.do?page=1&pageStart=0&option=<%=option%>&searchText=<%=searchText%>'>처음...</a> | |
236 | + <% | |
237 | + } | |
238 | + } else { | |
239 | + | |
240 | + } | |
241 | + if (currentPage <= 1) { | |
242 | + | |
243 | + } else { | |
244 | + int prePage = currentPage - 1; | |
245 | + if (request.getParameter("searchText") == null) { | |
246 | + %> | |
247 | + <a class="" | |
248 | + href='list.do?page=<%=prePage%>&pageStart=<%=prePage * 7 - 7%>'>이전</a> | |
249 | + <% | |
250 | + } else { | |
251 | + %> | |
252 | + <a class="pagingBtn" | |
253 | + href='list.do?page=<%=prePage%>&option=<%=option%>&searchText=<%=searchText%>&pageStart=<%=prePage * 7 - 7%>'>이전</a> | |
254 | + <% | |
255 | + } | |
256 | + } | |
257 | + for (int i = blockStart; i <= blockEnd; i++) { | |
258 | + if (currentPage == i) { | |
259 | + %> | |
260 | + <h2 id="h2"> | |
261 | + <u><%=i%></u> | |
262 | + </h2> | |
263 | + <% | |
264 | + } else { | |
265 | + if (request.getParameter("searchText") == null) { | |
266 | + %> | |
267 | + <a class="pagingBtn" | |
268 | + href="list.do?page=<%=i%>&pageStart=<%=i * list2 - 7%>"><%=i%></a> | |
269 | + <% | |
270 | + } else { | |
271 | + %> | |
272 | + <a class="pagingBtn" | |
273 | + href="list.do?page=<%=i%>&option=<%=option%>&searchText=<%=searchText%>&pageStart=<%=i * list2 - 7%>"><%=i%></a> | |
274 | + <% | |
275 | + } | |
276 | + } | |
277 | + } | |
278 | + if (currentPage >= totalPage) { | |
279 | + | |
280 | + } else { | |
281 | + int nextPage = currentPage + 1; | |
282 | + if (request.getParameter("searchText") == null) { | |
283 | + %> | |
284 | + <a class="pagingBtn" | |
285 | + href="list.do?page=<%=nextPage%>&pageStart=<%=nextPage * 7 - 7%>">다음</a> | |
286 | + <% | |
287 | + } else { | |
288 | + %> | |
289 | + <a class="pagingBtn" | |
290 | + href="list.do?page=<%=nextPage%>&option=<%=option%>&searchText=<%=searchText%>&pageStart=<%=nextPage * 7 - 7%>">다음</a> | |
291 | + <% | |
292 | + } | |
293 | + } | |
294 | + if (currentPage >= totalPage) { | |
295 | + | |
296 | + } else { | |
297 | + if (request.getParameter("searchText") == null) { | |
298 | + %> | |
299 | + <a class="pagingBtn" | |
300 | + href="list.do?page=<%=totalPage%>&pageStart=<%=totalPage * 7 - 7%>">...마지막</a> | |
301 | + <% | |
302 | + } else { | |
303 | + %> | |
304 | + <a class="pagingBtn" | |
305 | + href="list.do?page=<%=totalPage%>&option=<%=option%>&searchText=<%=searchText%>&pageStart=<%=totalPage * 7 - 7%>">...마지막</a> | |
306 | + <% | |
307 | + } | |
308 | + } | |
309 | + | |
310 | + } else { | |
311 | + | |
312 | + } | |
313 | + %> | |
314 | + </div> | |
315 | + <div id="bottomSector"> | |
316 | + <button id="btn" onClick="location.href='write.do'">글쓰기</button> | |
317 | + </div> | |
318 | + </div> | |
319 | +</body> | |
320 | +</html> | |
321 | + | |
322 | + | |
323 | + | |
324 | + | |
325 | + | |
326 | + | |
327 | + | |
328 | + | |
329 | + | |
330 | + | |
331 | + | |
332 | + | |
333 | + | |
334 | +' |
+++ src/main/webapp/view/login.jsp
... | ... | @@ -0,0 +1,12 @@ |
1 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
2 | + pageEncoding="UTF-8"%> | |
3 | +<!DOCTYPE html> | |
4 | +<html> | |
5 | +<head> | |
6 | +<meta charset="UTF-8"> | |
7 | +<title>Insert title here</title> | |
8 | +</head> | |
9 | +<body> | |
10 | + This is login Page | |
11 | +</body> | |
12 | +</html>(No newline at end of file) |
+++ src/main/webapp/view/update.jsp
... | ... | @@ -0,0 +1,81 @@ |
1 | +<%@page import="model.MemberDTO"%> | |
2 | +<%@page import="model.MemberDAO"%> | |
3 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
4 | + pageEncoding="UTF-8"%> | |
5 | +<% | |
6 | +int no = Integer.parseInt(request.getParameter("no")); | |
7 | +MemberDAO dao = new MemberDAO(); | |
8 | +MemberDTO member = new MemberDTO(); | |
9 | +member = dao.getMember(no); | |
10 | +%> | |
11 | +<!DOCTYPE html> | |
12 | +<html lang="ko"> | |
13 | +<head> | |
14 | +<meta charset="UTF-8"> | |
15 | +<title>Insert title here</title> | |
16 | +<style> | |
17 | +#page { | |
18 | + background-color: antiquewhite; | |
19 | + width: 80%; | |
20 | + margin: 0 auto; | |
21 | +} | |
22 | + | |
23 | +#top { | |
24 | + text-align: center; | |
25 | +} | |
26 | + | |
27 | +#middle { | |
28 | + text-align: right; | |
29 | +} | |
30 | + | |
31 | +#mainContents { | |
32 | + background-color: white; | |
33 | + width: 95%; | |
34 | + height: 300px; | |
35 | + border: 1px black solid; | |
36 | + margin-left: 25px; | |
37 | +} | |
38 | + | |
39 | +#innerContents { | |
40 | + margin-left: 30px; | |
41 | +} | |
42 | + | |
43 | +#crudButton { | |
44 | + text-align: right; | |
45 | + margin-right: 25px; | |
46 | +} | |
47 | + | |
48 | +#listBtn{ | |
49 | + position: relative; | |
50 | + left: 1400px; | |
51 | + bottom: 24px; | |
52 | +} | |
53 | + | |
54 | +</style> | |
55 | +</head> | |
56 | +<body> | |
57 | + <div id="page"> | |
58 | + <form action="updateComplite.do" method="post" id="form"> | |
59 | + <!-- Update 되는값들 전송 폼 --> | |
60 | + <div id="top"> | |
61 | + <h1> | |
62 | + 제목 : <input type="text" name="changeTitle" value="<%=member.getTitle()%>"> | |
63 | + </h1> | |
64 | + </div> | |
65 | + <hr /> | |
66 | + <div id="middle"> | |
67 | + <em>번호</em> : <strong><%=no%></strong> <input type="hidden" | |
68 | + name="no" value="<%=no%>"> <em>작성자</em> : <input | |
69 | + type="text" name="changeWriter" value="<%=member.getWriter()%>"> | |
70 | + <em>조회수</em> : <strong><%=member.getView()%></strong> | |
71 | + </div> | |
72 | + <br /> | |
73 | + <textarea id="mainContents" name="changeContents"><%=member.getContents()%></textarea> | |
74 | + <div id="crudButton"> | |
75 | + <br /> <input type="submit" value="확인"> | |
76 | + </div> | |
77 | + </form> | |
78 | + <button id="listBtn" onClick="location.href='list.do'">목록</button> | |
79 | + </div> | |
80 | +</body> | |
81 | +</html>(No newline at end of file) |
+++ src/main/webapp/view/write.jsp
... | ... | @@ -0,0 +1,45 @@ |
1 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
2 | + pageEncoding="UTF-8"%> | |
3 | +<!DOCTYPE html> | |
4 | +<html lang="ko"> | |
5 | +<head> | |
6 | +<meta charset="UTF-8"> | |
7 | +<title>Insert title here</title> | |
8 | +<style> | |
9 | +#page { | |
10 | + background-color: antiquewhite; | |
11 | + width: 80%; | |
12 | + margin: 0 auto; | |
13 | + text-align: center; | |
14 | + height: 430px; | |
15 | +} | |
16 | +#inputContent{ | |
17 | + width: 80%; | |
18 | + height: 200px; | |
19 | +} | |
20 | +#submit{ | |
21 | + float: right; | |
22 | +} | |
23 | +#bottomSector{ | |
24 | + width: 100%; | |
25 | +} | |
26 | +#btn{ | |
27 | + float: right; | |
28 | +} | |
29 | +</style> | |
30 | +</head> | |
31 | +<body> | |
32 | + <div id="page"> | |
33 | + <h1>This is write Page</h1> | |
34 | + <hr /> | |
35 | + <form action="insert" method="post" id="form" > | |
36 | + 작성자 : <input type="text" name="inputWriter"><br /> | |
37 | + 제목 : <input type="text" name="inputTitle"><br /> | |
38 | + 내용 : <textarea id="inputContent" name="inputContents"></textarea><br /> | |
39 | + 첨부파일 : <input type="file" name="file"> | |
40 | + <input id="submit" type="submit" value="등록"> | |
41 | + </form> | |
42 | + <div id="bottomSector"><button id="btn" onclick="location.href='list.do'">목록</button></div> | |
43 | + </div> | |
44 | +</body> | |
45 | +</html>(No newline at end of file) |
+++ target/classes/config/Database.class
Binary file is not shown |
+++ target/classes/config/EncodingFiter.class
Binary file is not shown |
+++ target/classes/control/MemberServlet.class
Binary file is not shown |
+++ target/classes/model/MemberDAO.class
Binary file is not shown |
+++ target/classes/model/MemberDTO.class
Binary file is not shown |
+++ target/classes/model/ReplyDTO.class
Binary file is not shown |
+++ target/m2e-wtp/web-resources/META-INF/MANIFEST.MF
... | ... | @@ -0,0 +1,4 @@ |
1 | +Manifest-Version: 1.0 | |
2 | +Build-Jdk-Spec: 16 | |
3 | +Created-By: Maven Integration for Eclipse | |
4 | + |
+++ target/m2e-wtp/web-resources/META-INF/maven/WebTest/WebTest/pom.properties
... | ... | @@ -0,0 +1,7 @@ |
1 | +#Generated by Maven Integration for Eclipse | |
2 | +#Mon Aug 30 17:45:57 KST 2021 | |
3 | +m2e.projectLocation=C\:\\dev\\workspace_JSP\\JSP_Board | |
4 | +m2e.projectName=JSP_Board | |
5 | +groupId=WebTest | |
6 | +artifactId=WebTest | |
7 | +version=0.0.1-SNAPSHOT |
+++ target/m2e-wtp/web-resources/META-INF/maven/WebTest/WebTest/pom.xml
... | ... | @@ -0,0 +1,48 @@ |
1 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
2 | + <modelVersion>4.0.0</modelVersion> | |
3 | + <groupId>WebTest</groupId> | |
4 | + <artifactId>WebTest</artifactId> | |
5 | + <version>0.0.1-SNAPSHOT</version> | |
6 | + <packaging>war</packaging> | |
7 | + <dependencies> | |
8 | + <dependency> | |
9 | + <groupId>mysql</groupId> | |
10 | + <artifactId>mysql-connector-java</artifactId> | |
11 | + <version>5.1.49</version> | |
12 | + </dependency> | |
13 | + <dependency> | |
14 | + <groupId>org.junit.jupiter</groupId> | |
15 | + <artifactId>junit-jupiter-api</artifactId> | |
16 | + <version>5.7.2</version> | |
17 | + <scope>test</scope> | |
18 | + </dependency> | |
19 | + <dependency> | |
20 | + <groupId>javax.servlet</groupId> | |
21 | + <artifactId>jstl</artifactId> | |
22 | + <version>1.2</version> | |
23 | + </dependency> | |
24 | + <dependency> | |
25 | + <groupId>org.apache.taglibs</groupId> | |
26 | + <artifactId>taglibs-standard-impl</artifactId> | |
27 | + <version>1.2.5</version> | |
28 | + <scope>runtime</scope> | |
29 | + </dependency> | |
30 | + | |
31 | + </dependencies> | |
32 | + <build> | |
33 | + <plugins> | |
34 | + <plugin> | |
35 | + <artifactId>maven-compiler-plugin</artifactId> | |
36 | + <version>3.8.1</version> | |
37 | + <configuration> | |
38 | + <source>1.8</source> | |
39 | + <target>1.8</target> | |
40 | + </configuration> | |
41 | + </plugin> | |
42 | + <plugin> | |
43 | + <artifactId>maven-war-plugin</artifactId> | |
44 | + <version>3.2.3</version> | |
45 | + </plugin> | |
46 | + </plugins> | |
47 | + </build> | |
48 | +</project>(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?