annotate src/jungle/test/bbs/EditMessageServlet.java @ 38:d8ee57a1c2c6

add pom.xml and bbs
author one
date Mon, 08 Jul 2013 20:25:58 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
1 package jungle.test.bbs;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
2
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
3 import java.io.PrintWriter;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
4
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
5 import javax.servlet.http.HttpServlet;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
6 import javax.servlet.http.HttpServletRequest;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
7 import javax.servlet.http.HttpServletResponse;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
8
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
9 public class EditMessageServlet extends HttpServlet
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
10 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
11 private final BulletinBoard bbs;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
12 private static final String PARAM_BOARD_NAME = "bname";
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
13 private static final String PARAM_BOARD_MSGID = "uuid";
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
14 private static final String PARAM_BOARD_AUTHOR = "author";
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
15 private static final String PARAM_BOARD_MESSAGE= "msg";
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
16 private static final String PARAM_BOARD_EDITKEY = "key";
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
17
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
18 private static final long serialVersionUID = 1L;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
19
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
20 public EditMessageServlet(BulletinBoard _bbs)
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
21 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
22 bbs = _bbs;
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
23 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
24
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
25 public void doGet(HttpServletRequest _req,HttpServletResponse _res)
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
26 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
27 String bname = _req.getParameter(PARAM_BOARD_NAME);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
28 String uuid = _req.getParameter(PARAM_BOARD_MSGID);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
29
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
30
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
31 try{
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
32 PrintWriter pw = _res.getWriter();
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
33 pw.write("<html><body><h1>edit message</h1>");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
34 pw.write("<form method='POST'\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
35 pw.write("<p>Author : <input type='text' name='author'/>" +
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
36 "<input type='hidden' name='key' value='"+uuid+"'/>" +
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
37 "<input type='hidden' name='bname' value='"+bname+"'</p>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
38 pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
39 pw.write("<p><input type='submit' value='submit'/></p>\n");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
40 pw.write("</body></html>");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
41 pw.flush();
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
42 }catch(Exception _e){
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
43 _res.setStatus(500);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
44 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
45 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
46
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
47 public void doPost(HttpServletRequest _req,HttpServletResponse _res)
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
48 {
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
49 String boardName = _req.getParameter(PARAM_BOARD_NAME);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
50 String author = _req.getParameter(PARAM_BOARD_AUTHOR);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
51 String msg = _req.getParameter(PARAM_BOARD_MESSAGE);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
52 String key = _req.getParameter(PARAM_BOARD_EDITKEY);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
53 String uuid = _req.getParameter(PARAM_BOARD_MSGID);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
54
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
55 try{
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
56 bbs.editMessage(boardName, uuid, author, msg, key);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
57 PrintWriter pw = _res.getWriter();
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
58 pw.write("successfully written");
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
59 pw.flush();
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
60 }catch(Exception _e){
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
61 _res.setStatus(500);
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
62 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
63 }
d8ee57a1c2c6 add pom.xml and bbs
one
parents:
diff changeset
64 }