Mercurial > hg > Database > jungle-network
annotate src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java @ 165:b3d5fbe95b9a
Create Folder Method
author | tatsuki |
---|---|
date | Mon, 28 Jul 2014 14:09:54 +0900 |
parents | cd4d64249931 |
children | 564f683b7aef |
rev | line source |
---|---|
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 package app.bbs; |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 import java.io.PrintWriter; |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 import javax.servlet.http.HttpServlet; |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 import javax.servlet.http.HttpServletRequest; |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 import javax.servlet.http.HttpServletResponse; |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 |
155 | 9 import org.eclipse.jetty.util.thread.ThreadPool; |
10 | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage; |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 |
156 | 13 public class ShowMessageWithTimeStampServlet extends HttpServlet { |
165 | 14 /** |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 * |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 */ |
165 | 17 private static final long serialVersionUID = 1L; |
18 private final NetworkBulletinBoard bbs; | |
19 private final String createBoardMessagePath; | |
20 private final String editMessagePath; | |
21 private final String showMatrixPath; | |
156 | 22 |
165 | 23 private static final String PARAM_BOARD_NAME = "bname"; |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 |
165 | 25 public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs, |
26 String _createBoardMessagePath, String _editMessagePath, String _showMatrixPath, | |
27 ThreadPool thp) { | |
28 bbs = _bbs; | |
29 showMatrixPath = _showMatrixPath; | |
30 createBoardMessagePath = _createBoardMessagePath; | |
31 editMessagePath = _editMessagePath; | |
32 } | |
156 | 33 |
165 | 34 public void doGet(HttpServletRequest _req, HttpServletResponse _res) { |
35 final String bname = _req.getParameter(PARAM_BOARD_NAME); | |
36 final String name = _req.getParameter("key"); | |
37 try { | |
38 printBoard(bname, _res.getWriter()); | |
39 } catch (Exception _e) { | |
40 _res.setStatus(500); | |
41 } | |
42 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 |
165 | 44 private void printBoard(String _bname, PrintWriter _pw) throws Exception { |
45 _pw.write("<html><body>\n"); | |
46 _pw.write("<h1>" + _bname + "</h1>\n"); | |
47 _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) | |
48 + "</p>\n"); | |
49 ; | |
50 | |
51 _pw.write("<form action='" + createBoardMessagePath | |
52 + "' method='POST'\n"); | |
53 _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='" | |
54 + _bname | |
55 + "'/> EditKey : <input type='text' name='key'/></p>\n"); | |
56 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); | |
57 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
156 | 58 |
165 | 59 |
60 for (BoardMessage msg : bbs.getMessages(_bname)) {//フォルダの表示 | |
61 _pw.write("<hr/>"); | |
62 _pw.write("<p><b>" + msg.getAuthor() + "</b></p>"); | |
63 _pw.write("<p>" + msg.getMessage() + "</p>"); | |
64 _pw.write("<small><a href=" + showMatrixPath + "?bname=" + _bname | |
65 + "&uuid=0" + ">"+msg.getMessage()+"(show matrix)"+"</a></small><br>"); | |
66 _pw.write("<small><a href='" + editMessagePath + "?bname=" + _bname | |
67 + "&uuid=" + msg.getUUID() + "'>edit</a></small>"); | |
68 } | |
156 | 69 |
165 | 70 //forコメントの表示 |
71 _pw.write("</body></html>"); | |
72 _pw.flush(); | |
73 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 } |