4
|
1 package jp.ac.u_ryukyu.ie.cr.bbs.browsing;
|
1
|
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;
|
4
|
14 private final BrowsingBulletinBoard bbs;
|
1
|
15 private final String createBoardPath;
|
|
16 private final String showBoardMessagePath;
|
5
|
17 private final String layoutImportPath;
|
|
18 private final String findNodePath;
|
|
19 public ShowBoardsServlet(BrowsingBulletinBoard _bbs, String _createBoardPath,String _showBoardMessagePath,String _layoutImportPath, String _findNodePath)
|
1
|
20 {
|
|
21 bbs = _bbs;
|
5
|
22 findNodePath = _findNodePath;
|
1
|
23 createBoardPath = _createBoardPath;
|
|
24 showBoardMessagePath = _showBoardMessagePath;
|
5
|
25 layoutImportPath = _layoutImportPath;
|
1
|
26 }
|
|
27
|
|
28 public void doGet(HttpServletRequest _req,HttpServletResponse _res)
|
|
29 {
|
|
30 try{
|
|
31 _res.setCharacterEncoding("UTF-8");
|
|
32 printBoard(_res.getWriter());
|
|
33 }catch(Exception _e){
|
|
34 _res.setStatus(500);
|
|
35 }
|
|
36
|
|
37 }
|
|
38
|
|
39 private void printBoard(PrintWriter _pw) throws Exception
|
|
40 {
|
|
41 _pw.write("<html><body>\n");
|
|
42 _pw.write("<h1>BBS</h1>\n");
|
|
43 _pw.write("<form action='"+createBoardPath+"' method='POST'\n");
|
|
44 _pw.write("<p>Create new board.</p>");
|
|
45 _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n");
|
5
|
46 _pw.write("<p><input type='submit' value='submit'/></form></p><hr/>\n");
|
|
47
|
|
48 _pw.write("<form action='"+layoutImportPath+"' method='POST'\n");
|
|
49 _pw.write("<p>import layoutFile</p>");
|
|
50 _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n");
|
|
51 _pw.write("<p>layout path : <input type='text' name='path'/></p>\n");
|
|
52 _pw.write("<p><input type='submit' value='submit'/></form></p><hr/>\n");
|
|
53
|
1
|
54 _pw.write("<h2>list of boards</h2>");
|
|
55 for(String board : bbs.getBoards()){
|
5
|
56 _pw.write("<p><a href='"+showBoardMessagePath+"?bname=" + bbs.sanitize(board) + "&path=-1" +"'>"+ bbs.sanitize(board) + "</a> " +
|
|
57 "<a href='"+findNodePath+"?bname=" + bbs.sanitize(board) +"'>"+ "find</a>"
|
|
58 + "</p>");
|
1
|
59 }
|
|
60
|
|
61 _pw.write("</body></html>");
|
|
62 _pw.flush();
|
|
63 }
|
|
64 }
|