Mercurial > hg > Database > jungle-network
comparison src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java @ 146:29734d7d6521
Added ShowMessageWithTimeStampServlet
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 28 Jan 2014 08:47:45 +0900 |
parents | |
children | 83e99eba6ec1 |
comparison
equal
deleted
inserted
replaced
145:0340a3321e6c | 146:29734d7d6521 |
---|---|
1 package 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 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage; | |
10 | |
11 public class ShowMessageWithTimeStampServlet extends HttpServlet | |
12 { | |
13 /** | |
14 * | |
15 */ | |
16 private static final long serialVersionUID = 1L; | |
17 private final NetworkBulletinBoard bbs; | |
18 private final String createBoardMessagePath; | |
19 private final String editMessagePath; | |
20 | |
21 private static final String PARAM_BOARD_NAME = "bname"; | |
22 | |
23 public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs,String _createBoardMessagePath, String _editMessagePath) | |
24 { | |
25 bbs = _bbs; | |
26 createBoardMessagePath = _createBoardMessagePath; | |
27 editMessagePath = _editMessagePath; | |
28 } | |
29 | |
30 public void doGet(HttpServletRequest _req,HttpServletResponse _res) | |
31 { | |
32 String bname = _req.getParameter(PARAM_BOARD_NAME); | |
33 | |
34 try{ | |
35 printBoard(bname,_res.getWriter()); | |
36 }catch(Exception _e){ | |
37 _res.setStatus(500); | |
38 } | |
39 | |
40 } | |
41 | |
42 private void printBoard(String _bname,PrintWriter _pw) throws Exception | |
43 { | |
44 _pw.write("<html><body>\n"); | |
45 _pw.write("<h1>"+_bname+"</h1>\n"); | |
46 _pw.write("<p>Latest renew time : "+bbs.getRenewTime(_bname)+"</p>\n");; | |
47 | |
48 _pw.write("<form action='"+createBoardMessagePath+"' method='POST'\n"); | |
49 _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='"+_bname+"'/> EditKey : <input type='text' name='key'/></p>\n"); | |
50 _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); | |
51 _pw.write("<p><input type='submit' value='submit'/></p>\n"); | |
52 | |
53 for(BoardMessage msg : bbs.getMessages(_bname)){ | |
54 _pw.write("<hr/>"); | |
55 _pw.write("<p><b>"+msg.getAuthor()+"</b></p>"); | |
56 _pw.write("<p>"+msg.getMessage()+"</p>"); | |
57 _pw.write("<small><a href='"+editMessagePath+"?bname="+_bname+"&uuid="+msg.getUUID()+"'>edit</a></small>"); | |
58 } | |
59 | |
60 _pw.write("</body></html>"); | |
61 _pw.flush(); | |
62 } | |
63 } |