Mercurial > hg > Members > nobuyasu > jungle-network
annotate src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java @ 193:89c15aa2bc6d
change transaction
author | tatsuki |
---|---|
date | Fri, 20 Mar 2015 16:18:42 +0900 |
parents | 3202a2a427b1 |
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; |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.GetAttributeImp; | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 |
156 | 14 public class ShowMessageWithTimeStampServlet extends HttpServlet { |
166 | 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 */ |
166 | 18 private static final long serialVersionUID = 1L; |
19 private final NetworkBulletinBoard bbs; | |
20 private final String createBoardMessagePath; | |
156 | 21 |
166 | 22 private static final String PARAM_BOARD_NAME = "bname"; |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 |
166 | 24 public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs, |
193 | 25 String _createBoardMessagePath, ThreadPool thp) { |
166 | 26 bbs = _bbs; |
27 createBoardMessagePath = _createBoardMessagePath; | |
28 } | |
156 | 29 |
166 | 30 public void doGet(HttpServletRequest _req, HttpServletResponse _res) { |
175 | 31 final String bname = (_req.getParameter(PARAM_BOARD_NAME)); |
166 | 32 try { |
174 | 33 _res.setCharacterEncoding("UTF-8"); |
166 | 34 printBoard(bname, _res.getWriter()); |
35 } catch (Exception _e) { | |
36 _res.setStatus(500); | |
37 } | |
38 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
166 | 40 private void printBoard(String _bname, PrintWriter _pw) throws Exception { |
41 _pw.write("<html><body>\n"); | |
176 | 42 _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n"); |
166 | 43 _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) |
44 + "</p>\n"); | |
168 | 45 ; |
46 | |
47 _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); | |
176 | 48 _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"); |
166 | 49 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); |
50 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
51 | |
192 | 52 GetAttributeImp attribute = bbs.getAttribute(_bname, "[-1]","0"); |
53 List<String> keys = attribute.getKeys(); | |
54 | |
55 for(String key : keys){ | |
56 String mesage = attribute.getMessage(key); | |
57 _pw.write("<p>" + key + " = " + mesage + "</p>\n"); | |
58 } | |
156 | 59 |
166 | 60 _pw.write("</body></html>"); |
61 _pw.flush(); | |
62 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 } |