Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/jungle/app/bbs/ShowBoardMessageServlet.java @ 66:29127ac788a6
move some files
author | one |
---|---|
date | Tue, 20 Aug 2013 17:38:09 +0900 |
parents | src/jungle/test/bbs/ShowBoardMessageServlet.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 ShowBoardMessageServlet extends HttpServlet | |
10 { | |
11 /** | |
12 * | |
13 */ | |
14 private static final long serialVersionUID = 1L; | |
15 private final BulletinBoard bbs; | |
16 private final String createBoardMessagePath; | |
17 private final String editMessagePath; | |
18 | |
19 private static final String PARAM_BOARD_NAME = "bname"; | |
20 | |
21 public ShowBoardMessageServlet(BulletinBoard _bbs,String _createBoardMessagePath, String _editMessagePath) | |
22 { | |
23 bbs = _bbs; | |
24 createBoardMessagePath = _createBoardMessagePath; | |
25 editMessagePath = _editMessagePath; | |
26 } | |
27 | |
28 public void doGet(HttpServletRequest _req,HttpServletResponse _res) | |
29 { | |
30 String bname = _req.getParameter(PARAM_BOARD_NAME); | |
31 | |
32 try{ | |
33 printBoard(bname,_res.getWriter()); | |
34 }catch(Exception _e){ | |
35 _res.setStatus(500); | |
36 } | |
37 | |
38 } | |
39 | |
40 private void printBoard(String _bname,PrintWriter _pw) throws Exception | |
41 { | |
42 _pw.write("<html><body>\n"); | |
43 _pw.write("<h1>"+_bname+"</h1>\n"); | |
44 | |
45 _pw.write("<form action='"+createBoardMessagePath+"' method='POST'\n"); | |
46 _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='"+_bname+"'/> EditKey : <input type='text' name='key'/></p>\n"); | |
47 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); | |
48 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
49 | |
50 for(BoardMessage msg : bbs.getMessages(_bname)){ | |
51 _pw.write("<hr/>"); | |
52 _pw.write("<p><b>"+msg.getAuthor()+"</b></p>"); | |
53 _pw.write("<p>"+msg.getMessage()+"</p>"); | |
54 _pw.write("<small><a href='"+editMessagePath+"?bname="+_bname+"&uuid="+msg.getUUID()+"'>edit</a></small>"); | |
55 } | |
56 | |
57 _pw.write("</body></html>"); | |
58 _pw.flush(); | |
59 } | |
60 } |