Mercurial > hg > Members > tatsuki > bbs
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/local/bbs/ShowBoardMessageServlet.java @ 8:766f7668521f
commit
author | tatsuki |
---|---|
date | Thu, 02 Feb 2017 23:05:59 +0900 |
parents | src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/local/ShowBoardMessageServlet.java@5acde010c6db |
children |
comparison
equal
deleted
inserted
replaced
7:6c584862fe93 | 8:766f7668521f |
---|---|
1 package jp.ac.u_ryukyu.ie.cr.bbs.local.bbs; | |
2 | |
3 import javax.servlet.http.HttpServlet; | |
4 import javax.servlet.http.HttpServletRequest; | |
5 import javax.servlet.http.HttpServletResponse; | |
6 import java.io.PrintWriter; | |
7 import java.util.Iterator; | |
8 | |
9 public class ShowBoardMessageServlet extends HttpServlet { | |
10 /** | |
11 * | |
12 */ | |
13 private static final long serialVersionUID = 1L; | |
14 private final BulletinBoard bbs; | |
15 private final String createBoardMessagePath; | |
16 | |
17 private static final String PARAM_BOARD_NAME = "bname"; | |
18 | |
19 public ShowBoardMessageServlet(BulletinBoard _bbs, String _createBoardMessagePath, String _editMessagePath) { | |
20 bbs = _bbs; | |
21 createBoardMessagePath = _createBoardMessagePath; | |
22 } | |
23 | |
24 public void doGet(HttpServletRequest _req, HttpServletResponse _res) { | |
25 String bname = _req.getParameter(PARAM_BOARD_NAME); | |
26 | |
27 try { | |
28 printBoard(bname, _res.getWriter()); | |
29 } catch (Exception _e) { | |
30 _res.setStatus(500); | |
31 } | |
32 | |
33 } | |
34 | |
35 private void printBoard(String _bname, PrintWriter _pw) throws Exception { | |
36 _pw.write("<html><body>\n"); | |
37 _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n"); | |
38 | |
39 _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); | |
40 _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='" + _bname + "'/> EditKey : <input type='text' name='key'/></p>\n"); | |
41 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); | |
42 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
43 GetAttributeImp attribute = bbs.getAttribute(_bname, "-1,0", "-1"); | |
44 | |
45 Iterator<String> keys = attribute.getKeys(); | |
46 | |
47 do { | |
48 String key = keys.next(); | |
49 String mesage = attribute.getMessage(key); | |
50 _pw.write("<p>" + key + " = " + mesage + "</p>\n"); | |
51 } while (keys.hasNext()); | |
52 | |
53 _pw.write("</body></html>"); | |
54 _pw.flush(); | |
55 } | |
56 } |