Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 236:9befc64affeb Implementation_of_communication
edit Message bug fix`
author | tatsuki |
---|---|
date | Sun, 24 Jan 2016 20:16:56 +0900 |
parents | faa9fa06ead1 |
children | 33c93f162389 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/bbs/ShowMessageWithTimeStampServlet.java |
diffstat | 1 files changed, 47 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/bbs/ShowMessageWithTimeStampServlet.java Sun Jan 24 18:51:47 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/bbs/ShowMessageWithTimeStampServlet.java Sun Jan 24 20:16:56 2016 +0900 @@ -10,53 +10,55 @@ import java.util.Iterator; public class ShowMessageWithTimeStampServlet extends HttpServlet { - /** - * - */ - private static final long serialVersionUID = 1L; - private final NetworkBulletinBoard bbs; - private final String createBoardMessagePath; - - private static final String PARAM_BOARD_NAME = "bname"; - - public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs, - String _createBoardMessagePath, ThreadPool thp) { - bbs = _bbs; - createBoardMessagePath = _createBoardMessagePath; - } + /** + * + */ + private static final long serialVersionUID = 1L; + private final NetworkBulletinBoard bbs; + private final String createBoardMessagePath; - public void doGet(HttpServletRequest _req, HttpServletResponse _res) { - final String bname = (_req.getParameter(PARAM_BOARD_NAME)); - try { - _res.setCharacterEncoding("UTF-8"); - printBoard(bname, _res.getWriter()); - } catch (Exception _e) { - _res.setStatus(500); - } - } + private static final String PARAM_BOARD_NAME = "bname"; + private final String editMessagePath; - private void printBoard(String _bname, PrintWriter _pw) throws Exception { - _pw.write("<html><body>\n"); - _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n"); - _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) - + "</p>\n"); - ; - - _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); - _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"); - _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); - _pw.write("<p><input type='submit' value='submit'/></p>\n"); - - GetAttributeImp attribute = bbs.getAttribute(_bname, "[-1]","0"); - Iterator<String> keys = attribute.getKeys(); - - while(keys.hasNext()){ - String key = keys.next(); - String mesage = attribute.getMessage(key); - _pw.write("<p>" + key + " = " + mesage + "</p>\n"); + public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs, + String _createBoardMessagePath, String _editMessagePath, ThreadPool thp) { + bbs = _bbs; + createBoardMessagePath = _createBoardMessagePath; + editMessagePath = _editMessagePath; } - _pw.write("</body></html>"); - _pw.flush(); - } + public void doGet(HttpServletRequest _req, HttpServletResponse _res) { + final String bname = (_req.getParameter(PARAM_BOARD_NAME)); + try { + _res.setCharacterEncoding("UTF-8"); + printBoard(bname, _res.getWriter()); + } catch (Exception _e) { + _res.setStatus(500); + } + } + + private void printBoard(String _bname, PrintWriter _pw) throws Exception { + _pw.write("<html><body>\n"); + _pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n"); + _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) + + "</p>\n"); + ; + + _pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n"); + _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"); + _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); + _pw.write("<p><input type='submit' value='submit'/></p>\n"); + + GetAttributeImp attribute = bbs.getAttribute(_bname, "[-1]", "0"); + Iterator<String> keys = attribute.getKeys(); + + while (keys.hasNext()) { + String key = keys.next(); + String mesage = attribute.getMessage(key); + _pw.write("<p>" + key + " = " + mesage + "</p>\n"); + } + _pw.write("<p><a href='" + editMessagePath + "?bname=" + bbs.sanitize(_bname) + "&uuid=-1,0" + "'>edit" + "</a></p>"); + _pw.write("</body></html>"); + _pw.flush(); + } }