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