1
|
1 package jp.ac.u_ryukyu.cr.ie.tatsuki.bbs;
|
|
2
|
|
3 import java.io.PrintWriter;
|
|
4
|
|
5 import javax.servlet.http.HttpServlet;
|
|
6 import javax.servlet.http.HttpServletRequest;
|
|
7 import javax.servlet.http.HttpServletResponse;
|
|
8
|
|
9
|
|
10 public class ShowBoardsServletMatrix extends HttpServlet
|
|
11 {
|
|
12 /**
|
|
13 *
|
|
14 */
|
|
15 private static final long serialVersionUID = 1L;
|
|
16 private final XmlBulletinBoard bbs;
|
|
17 private final String createBoardPath;
|
|
18 private final String showBoardMessagePath;
|
|
19
|
|
20 public ShowBoardsServletMatrix(XmlBulletinBoard _bbs, String _createBoardPath,String _showBoardMessagePath)
|
|
21 {
|
|
22 bbs = _bbs;
|
|
23 createBoardPath = _createBoardPath;
|
|
24 showBoardMessagePath = _showBoardMessagePath;
|
|
25 }
|
|
26
|
|
27 public void doGet(HttpServletRequest _req,HttpServletResponse _res)
|
|
28 {
|
|
29 try{
|
|
30 _res.setCharacterEncoding("UTF-8");
|
|
31 printBoard(_res.getWriter());
|
|
32 }catch(Exception _e){
|
|
33 _res.setStatus(500);
|
|
34 }
|
|
35
|
|
36 }
|
|
37
|
|
38 private void printBoard(PrintWriter _pw) throws Exception
|
|
39 {
|
|
40 _pw.write("<html><body>\n");
|
|
41 _pw.write("<h1>BBS</h1>\n");
|
|
42 _pw.write("<form action='"+createBoardPath+"' method='POST'\n");
|
|
43 _pw.write("<p>Create new board.</p>");
|
|
44 _pw.write("<p>XmlPath : <input type='text' name='xmlPath'/></p>\n");
|
|
45 _pw.write("<p><input type='submit' value='submit'/></p><hr/>\n");
|
|
46
|
|
47 _pw.write("<h2>list of boards</h2>");
|
|
48 for(String board : bbs.getBoards()){
|
|
49 _pw.write("<p><a href='"+showBoardMessagePath+"?bname=" + bbs.sanitize(board) + "'>"+ bbs.sanitize(board) + "</a></p>");
|
|
50 }
|
|
51
|
|
52 _pw.write("</body></html>");
|
|
53 _pw.flush();
|
|
54 }
|
|
55 }
|