annotate src/main/java/app/bbs/ShowBoardsServlet.java @ 112:8f9811a1e00c

Moved app files
author one
date Fri, 29 Nov 2013 04:31:22 +0900
parents src/main/java/jungle/app/bbs/ShowBoardsServlet.java@f9e29a52efd3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
112
8f9811a1e00c Moved app files
one
parents: 105
diff changeset
1 package app.bbs;
38
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
2
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
3 import java.io.PrintWriter;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
4
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
5 import javax.servlet.http.HttpServlet;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
6 import javax.servlet.http.HttpServletRequest;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
7 import javax.servlet.http.HttpServletResponse;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
8
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
9 public class ShowBoardsServlet extends HttpServlet
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
10 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
11 /**
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
12 *
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
13 */
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
14 private static final long serialVersionUID = 1L;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
15 private final BulletinBoard bbs;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
16 private final String createBoardPath;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
17 private final String showBoardMessagePath;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
18
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
19 public ShowBoardsServlet(BulletinBoard _bbs, String _createBoardPath,String _showBoardMessagePath)
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
20 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
21 bbs = _bbs;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
22 createBoardPath = _createBoardPath;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
23 showBoardMessagePath = _showBoardMessagePath;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
24 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
25
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
26 public void doGet(HttpServletRequest _req,HttpServletResponse _res)
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
27 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
28 try{
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
29 printBoard(_res.getWriter());
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
30 }catch(Exception _e){
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
31 _res.setStatus(500);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
32 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
33
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
34 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
35
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
36 private void printBoard(PrintWriter _pw) throws Exception
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
37 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
38 _pw.write("<html><body>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
39 _pw.write("<h1>BBS</h1>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
40 _pw.write("<form action='"+createBoardPath+"' method='POST'\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
41 _pw.write("<p>Create new board.</p>");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
42 _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
43 _pw.write("<p>Author : <input type='text' name='author'/> EditKey : <input type='text' name='key'/></p>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
44 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
45 _pw.write("<p><input type='submit' value='submit'/></p><hr/>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
46
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
47 _pw.write("<h2>list of boards</h2>");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
48 for(String board : bbs.getBoards()){
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
49 _pw.write("<p><a href='"+showBoardMessagePath+"?bname="+board+"'>"+board+"</a></p>");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
50 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
51
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
52 _pw.write("</body></html>");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
53 _pw.flush();
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
54 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
55 }