1
|
1 package jp.ac.u_ryukyu.cr.ie.tatsuki.bbs;
|
|
2
|
|
3 import java.io.PrintWriter;
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11 import javax.servlet.http.HttpServlet;
|
|
12 import javax.servlet.http.HttpServletRequest;
|
|
13 import javax.servlet.http.HttpServletResponse;
|
|
14
|
|
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage;
|
|
16 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard;
|
|
17
|
|
18 public class ShowMessageWithTimeStampServletMatrix extends HttpServlet {
|
|
19 /**
|
|
20 *
|
|
21 */
|
|
22 private static final long serialVersionUID = 1L;
|
|
23 private final XmlBulletinBoard bbs;
|
|
24 private final String createBoardMessagePath;
|
|
25 private final String editMessagePath;
|
|
26 private final String showMatrixPath;
|
|
27
|
|
28 private static final String PARAM_BOARD_NAME = "bname";
|
|
29
|
|
30 public ShowMessageWithTimeStampServletMatrix(XmlBulletinBoard _bbs,
|
|
31 String _createBoardMessagePath, String _editMessagePath, String _showMatrixPath) {
|
|
32 bbs = _bbs;
|
|
33 showMatrixPath = _showMatrixPath;
|
|
34 createBoardMessagePath = _createBoardMessagePath;
|
|
35 editMessagePath = _editMessagePath;
|
|
36 }
|
|
37
|
|
38 public void doGet(HttpServletRequest _req, HttpServletResponse _res) {
|
|
39 final String bname = (_req.getParameter(PARAM_BOARD_NAME));
|
|
40 try {
|
|
41 _res.setCharacterEncoding("UTF-8");
|
|
42 printBoard(bname, _res.getWriter());
|
|
43 } catch (Exception _e) {
|
|
44 _res.setStatus(500);
|
|
45 }
|
|
46 }
|
|
47
|
|
48 private void printBoard(String _bname, PrintWriter _pw) throws Exception {
|
|
49 _pw.write("<html><body>\n");
|
|
50 _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n");
|
|
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='" +bbs.sanitize( _bname) + "'/> EditKey : <input type='textarea' name='key'/></p>\n");
|
|
54 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n");
|
|
55 _pw.write("<p><input type='submit' value='submit'/></p>\n");
|
|
56 _pw.write("<small><a href=" + showMatrixPath + "?bname=" + bbs.sanitize(_bname) + "&uuid= >MatrixMode"+"</a></small><br>");
|
|
57
|
|
58 for (BoardMessage msg : bbs.getMessages(_bname)) {//フォルダの表示
|
|
59 _pw.write("<hr/>");
|
|
60 _pw.write("<p> Author <b>" + bbs.sanitize(msg.getAuthor()) + "</b></p>");
|
|
61 _pw.write("<small><a href=" + editMessagePath + "?bname=" + bbs.sanitize(_bname)
|
|
62 + "&uuid=" + msg.getUUID() + ">"+ bbs.sanitize(msg.getMessage()) +"</a></small><br>");
|
|
63 }
|
|
64
|
|
65 _pw.write("</body></html>");
|
|
66 _pw.flush();
|
|
67 }
|
|
68 }
|