Mercurial > hg > Members > nobuyasu > jungle-network
annotate src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java @ 168:91f6dd655a01
refactoring
author | tatsuki |
---|---|
date | Tue, 29 Jul 2014 10:58:11 +0900 |
parents | 564f683b7aef |
children | e30880a72909 |
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 { |
166 | 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 */ |
166 | 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 |
166 | 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 |
166 | 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 |
166 | 34 public void doGet(HttpServletRequest _req, HttpServletResponse _res) { |
35 final String bname = _req.getParameter(PARAM_BOARD_NAME); | |
36 try { | |
37 printBoard(bname, _res.getWriter()); | |
38 } catch (Exception _e) { | |
39 _res.setStatus(500); | |
40 } | |
41 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 |
166 | 43 private void printBoard(String _bname, PrintWriter _pw) throws Exception { |
44 _pw.write("<html><body>\n"); | |
45 _pw.write("<h1>" + _bname + "</h1>\n"); | |
46 _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) | |
47 + "</p>\n"); | |
168 | 48 ; |
49 | |
50 _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); | |
51 _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='" + _bname + "'/> EditKey : <input type='text' name='key'/></p>\n"); | |
166 | 52 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); |
53 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
168 | 54 _pw.write("<small><a href=" + showMatrixPath + "?bname=" + _bname + "&uuid= >MatrixMode"+"</a></small><br>"); |
166 | 55 |
56 for (BoardMessage msg : bbs.getMessages(_bname)) {//フォルダの表示 | |
57 _pw.write("<hr/>"); | |
168 | 58 _pw.write("<p> Author <b>" + msg.getAuthor() + "</b></p>"); |
59 _pw.write("<small><a href=" + editMessagePath + "?bname=" + _bname | |
60 + "&uuid=" + msg.getUUID() + ">"+ msg.getMessage() +"</a></small><br>"); | |
166 | 61 } |
156 | 62 |
166 | 63 //forコメントの表示 |
64 _pw.write("</body></html>"); | |
65 _pw.flush(); | |
66 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 } |