Mercurial > hg > Members > tatsuki > bbs
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/local/browsing/ShowBoardsServlet.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/browsing/ShowBoardsServlet.java@6c584862fe93 |
children |
comparison
equal
deleted
inserted
replaced
7:6c584862fe93 | 8:766f7668521f |
---|---|
1 package jp.ac.u_ryukyu.ie.cr.bbs.local.browsing; | |
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 | |
8 public class ShowBoardsServlet extends HttpServlet | |
9 { | |
10 /** | |
11 * | |
12 */ | |
13 private static final long serialVersionUID = 1L; | |
14 private final BrowsingBulletinBoard bbs; | |
15 private final String createBoardPath; | |
16 private final String showBoardMessagePath; | |
17 private final String findNodePath; | |
18 public ShowBoardsServlet(BrowsingBulletinBoard _bbs, String _createBoardPath,String _showBoardMessagePath, String _findNodePath) | |
19 { | |
20 bbs = _bbs; | |
21 findNodePath = _findNodePath; | |
22 createBoardPath = _createBoardPath; | |
23 showBoardMessagePath = _showBoardMessagePath; | |
24 } | |
25 | |
26 public void doGet(HttpServletRequest _req,HttpServletResponse _res) | |
27 { | |
28 try{ | |
29 _res.setCharacterEncoding("UTF-8"); | |
30 printBoard(_res.getWriter()); | |
31 }catch(Exception _e){ | |
32 _res.setStatus(500); | |
33 } | |
34 | |
35 } | |
36 | |
37 private void printBoard(PrintWriter _pw) throws Exception | |
38 { | |
39 _pw.write("<html><body>\n"); | |
40 _pw.write("<h1>BBS</h1>\n"); | |
41 _pw.write("<form action='"+createBoardPath+"' method='POST'\n"); | |
42 _pw.write("<p>Create new board.</p>"); | |
43 _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n"); | |
44 _pw.write("<p><input type='submit' value='submit'/></form></p><hr/>\n"); | |
45 | |
46 _pw.write("<h2>list of boards</h2>"); | |
47 for(String board : bbs.getBoards()){ | |
48 _pw.write("<p><a href='"+showBoardMessagePath+"?bname=" + bbs.sanitize(board) + "&path=-1" +"'>"+ bbs.sanitize(board) + "</a> " + | |
49 "<a href='"+findNodePath+"?bname=" + bbs.sanitize(board) +"'>"+ "find</a>" | |
50 + "</p>"); | |
51 } | |
52 | |
53 _pw.write("</body></html>"); | |
54 _pw.flush(); | |
55 } | |
56 } |