Mercurial > hg > Members > nobuyasu > jungle-network
annotate src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java @ 190:269bada9eedc
add
author | tatsuki |
---|---|
date | Fri, 17 Oct 2014 15:16:56 +0900 |
parents | 6f104ab4eb81 |
children | 3202a2a427b1 |
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; | |
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, |
190 | 25 String _createBoardMessagePath, String _editMessagePath,ThreadPool thp) { |
166 | 26 bbs = _bbs; |
27 createBoardMessagePath = _createBoardMessagePath; | |
28 editMessagePath = _editMessagePath; | |
29 } | |
156 | 30 |
166 | 31 public void doGet(HttpServletRequest _req, HttpServletResponse _res) { |
175 | 32 final String bname = (_req.getParameter(PARAM_BOARD_NAME)); |
166 | 33 try { |
174 | 34 _res.setCharacterEncoding("UTF-8"); |
166 | 35 printBoard(bname, _res.getWriter()); |
36 } catch (Exception _e) { | |
37 _res.setStatus(500); | |
38 } | |
39 } | |
146
29734d7d6521
Added ShowMessageWithTimeStampServlet
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 |
166 | 41 private void printBoard(String _bname, PrintWriter _pw) throws Exception { |
42 _pw.write("<html><body>\n"); | |
176 | 43 _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n"); |
166 | 44 _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) |
45 + "</p>\n"); | |
168 | 46 ; |
47 | |
48 _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); | |
176 | 49 _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 | 50 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); |
51 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
52 | |
53 for (BoardMessage msg : bbs.getMessages(_bname)) {//フォルダの表示 | |
54 _pw.write("<hr/>"); | |
176 | 55 _pw.write("<p> Author <b>" + bbs.sanitize(msg.getAuthor()) + "</b></p>"); |
56 _pw.write("<small><a href=" + editMessagePath + "?bname=" + bbs.sanitize(_bname) | |
57 + "&uuid=" + msg.getUUID() + ">"+ bbs.sanitize(msg.getMessage()) +"</a></small><br>"); | |
166 | 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 } |