Mercurial > hg > Database > jungle-network
comparison src/jungle/app/bbs/ShowBoardsServlet.java @ 66:29127ac788a6
move some files
author | one |
---|---|
date | Tue, 20 Aug 2013 17:38:09 +0900 |
parents | src/jungle/test/bbs/ShowBoardsServlet.java@d8ee57a1c2c6 |
children |
comparison
equal
deleted
inserted
replaced
65:ebf42371454b | 66:29127ac788a6 |
---|---|
1 package jungle.app.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 public class ShowBoardsServlet extends HttpServlet | |
10 { | |
11 /** | |
12 * | |
13 */ | |
14 private static final long serialVersionUID = 1L; | |
15 private final BulletinBoard bbs; | |
16 private final String createBoardPath; | |
17 private final String showBoardMessagePath; | |
18 | |
19 public ShowBoardsServlet(BulletinBoard _bbs, String _createBoardPath,String _showBoardMessagePath) | |
20 { | |
21 bbs = _bbs; | |
22 createBoardPath = _createBoardPath; | |
23 showBoardMessagePath = _showBoardMessagePath; | |
24 } | |
25 | |
26 public void doGet(HttpServletRequest _req,HttpServletResponse _res) | |
27 { | |
28 try{ | |
29 printBoard(_res.getWriter()); | |
30 }catch(Exception _e){ | |
31 _res.setStatus(500); | |
32 } | |
33 | |
34 } | |
35 | |
36 private void printBoard(PrintWriter _pw) throws Exception | |
37 { | |
38 _pw.write("<html><body>\n"); | |
39 _pw.write("<h1>BBS</h1>\n"); | |
40 _pw.write("<form action='"+createBoardPath+"' method='POST'\n"); | |
41 _pw.write("<p>Create new board.</p>"); | |
42 _pw.write("<p>BoardName : <input type='text' name='bname'/></p>\n"); | |
43 _pw.write("<p>Author : <input type='text' name='author'/> EditKey : <input type='text' name='key'/></p>\n"); | |
44 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </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="+board+"'>"+board+"</a></p>"); | |
50 } | |
51 | |
52 _pw.write("</body></html>"); | |
53 _pw.flush(); | |
54 } | |
55 } |