Mercurial > hg > Database > jungle-network
annotate src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java @ 192:3202a2a427b1 default tip
bug fix
author | tatsuki |
---|---|
date | Tue, 20 Jan 2015 09:30:59 +0900 |
parents | 269bada9eedc |
children |
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 | |
192 | 11 import fj.data.List; |
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; |
192 | 13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.GetAttributeImp; |
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 |
156 | 16 public class ShowMessageWithTimeStampServlet extends HttpServlet { |
165 | 17 /** |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 * |
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 */ |
165 | 20 private static final long serialVersionUID = 1L; |
21 private final NetworkBulletinBoard bbs; | |
22 private final String createBoardMessagePath; | |
23 private final String editMessagePath; | |
156 | 24 |
165 | 25 private static final String PARAM_BOARD_NAME = "bname"; |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
165 | 27 public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs, |
190 | 28 String _createBoardMessagePath, String _editMessagePath,ThreadPool thp) { |
165 | 29 bbs = _bbs; |
30 createBoardMessagePath = _createBoardMessagePath; | |
31 editMessagePath = _editMessagePath; | |
32 } | |
156 | 33 |
165 | 34 public void doGet(HttpServletRequest _req, HttpServletResponse _res) { |
174 | 35 final String bname = (_req.getParameter(PARAM_BOARD_NAME)); |
165 | 36 try { |
173 | 37 _res.setCharacterEncoding("UTF-8"); |
165 | 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"); | |
175 | 46 _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n"); |
165 | 47 _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) |
48 + "</p>\n"); | |
167 | 49 ; |
50 | |
51 _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); | |
175 | 52 _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='" +bbs.sanitize( _bname) + "'/> EditKey : <input type='textarea' name='key'/></p>\n"); |
165 | 53 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); |
54 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
55 | |
192 | 56 GetAttributeImp attribute = bbs.getAttribute(_bname, "[-1]","0"); |
57 List<String> keys = attribute.getKeys(); | |
58 | |
59 for(String key : keys){ | |
60 String mesage = attribute.getMessage(key); | |
61 _pw.write("<p>" + key + " = " + mesage + "</p>\n"); | |
62 } | |
156 | 63 |
165 | 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 } |