38
|
1 package jungle.test.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 CreateBoardServlet extends HttpServlet
|
|
10 {
|
|
11 private final BulletinBoard bbs;
|
|
12 private static final String PARAM_BOARD_NAME = "bname";
|
|
13 private static final String PARAM_BOARD_AUTHOR = "author";
|
|
14 private static final String PARAM_BOARD_INITMESSAGE= "msg";
|
|
15 private static final String PARAM_BOARD_EDITKEY = "key";
|
|
16
|
|
17 private static final long serialVersionUID = 1L;
|
|
18
|
|
19 public CreateBoardServlet(BulletinBoard _bbs)
|
|
20 {
|
|
21 bbs = _bbs;
|
|
22 }
|
|
23
|
|
24 public void doPost(HttpServletRequest _req,HttpServletResponse _res)
|
|
25 {
|
|
26 String boardName = _req.getParameter(PARAM_BOARD_NAME);
|
|
27 String author = _req.getParameter(PARAM_BOARD_AUTHOR);
|
|
28 String msg = _req.getParameter(PARAM_BOARD_INITMESSAGE);
|
|
29 String key = _req.getParameter(PARAM_BOARD_EDITKEY);
|
|
30
|
|
31 try{
|
|
32 bbs.createBoards(boardName,author,msg,key);
|
|
33 PrintWriter pw = _res.getWriter();
|
|
34 pw.write("successfully written");
|
|
35 }catch(Exception _e){
|
|
36 _res.setStatus(500);
|
|
37 }
|
|
38 }
|
|
39 }
|