Mercurial > hg > Members > nobuyasu > jungle-network
view src/jungle/app/bbs/ShowBoardMessageServlet.java @ 66:29127ac788a6
move some files
author | one |
---|---|
date | Tue, 20 Aug 2013 17:38:09 +0900 |
parents | src/jungle/test/bbs/ShowBoardMessageServlet.java@d8ee57a1c2c6 |
children |
line wrap: on
line source
package jungle.app.bbs; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ShowBoardMessageServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; private final BulletinBoard bbs; private final String createBoardMessagePath; private final String editMessagePath; private static final String PARAM_BOARD_NAME = "bname"; public ShowBoardMessageServlet(BulletinBoard _bbs,String _createBoardMessagePath, String _editMessagePath) { bbs = _bbs; createBoardMessagePath = _createBoardMessagePath; editMessagePath = _editMessagePath; } public void doGet(HttpServletRequest _req,HttpServletResponse _res) { String bname = _req.getParameter(PARAM_BOARD_NAME); try{ 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>"+_bname+"</h1>\n"); _pw.write("<form action='"+createBoardMessagePath+"' method='POST'\n"); _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='"+_bname+"'/> EditKey : <input type='text' 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"); for(BoardMessage msg : bbs.getMessages(_bname)){ _pw.write("<hr/>"); _pw.write("<p><b>"+msg.getAuthor()+"</b></p>"); _pw.write("<p>"+msg.getMessage()+"</p>"); _pw.write("<small><a href='"+editMessagePath+"?bname="+_bname+"&uuid="+msg.getUUID()+"'>edit</a></small>"); } _pw.write("</body></html>"); _pw.flush(); } }