Mercurial > hg > Members > shoshi > jungle > bbs
view src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/browsing/ShowBoardsServlet.java @ 5:2b3542c5be34
move child
author | tatsuki |
---|---|
date | Tue, 02 Aug 2016 17:46:03 +0900 |
parents | 5acde010c6db |
children | 6c584862fe93 |
line wrap: on
line source
package jp.ac.u_ryukyu.ie.cr.bbs.browsing; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; public class ShowBoardsServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; private final BrowsingBulletinBoard bbs; private final String createBoardPath; private final String showBoardMessagePath; private final String layoutImportPath; private final String findNodePath; public ShowBoardsServlet(BrowsingBulletinBoard _bbs, String _createBoardPath,String _showBoardMessagePath,String _layoutImportPath, String _findNodePath) { bbs = _bbs; findNodePath = _findNodePath; createBoardPath = _createBoardPath; showBoardMessagePath = _showBoardMessagePath; layoutImportPath = _layoutImportPath; } public void doGet(HttpServletRequest _req,HttpServletResponse _res) { try{ _res.setCharacterEncoding("UTF-8"); printBoard(_res.getWriter()); }catch(Exception _e){ _res.setStatus(500); } } private void printBoard(PrintWriter _pw) throws Exception { _pw.write("<html><body>\n"); _pw.write("<h1>BBS</h1>\n"); _pw.write("<form action='"+createBoardPath+"' method='POST'\n"); _pw.write("<p>Create new board.</p>"); _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n"); _pw.write("<p><input type='submit' value='submit'/></form></p><hr/>\n"); _pw.write("<form action='"+layoutImportPath+"' method='POST'\n"); _pw.write("<p>import layoutFile</p>"); _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n"); _pw.write("<p>layout path : <input type='text' name='path'/></p>\n"); _pw.write("<p><input type='submit' value='submit'/></form></p><hr/>\n"); _pw.write("<h2>list of boards</h2>"); for(String board : bbs.getBoards()){ _pw.write("<p><a href='"+showBoardMessagePath+"?bname=" + bbs.sanitize(board) + "&path=-1" +"'>"+ bbs.sanitize(board) + "</a> " + "<a href='"+findNodePath+"?bname=" + bbs.sanitize(board) +"'>"+ "find</a>" + "</p>"); } _pw.write("</body></html>"); _pw.flush(); } }