Mercurial > hg > Database > jungle-network
view src/jungle/app/bbs/EditMessageServlet.java @ 66:29127ac788a6
move some files
author | one |
---|---|
date | Tue, 20 Aug 2013 17:38:09 +0900 |
parents | src/jungle/test/bbs/EditMessageServlet.java@d8ee57a1c2c6 |
children |
line wrap: on
line source
package jungle.app.bbs; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class EditMessageServlet extends HttpServlet { private final BulletinBoard bbs; private static final String PARAM_BOARD_NAME = "bname"; private static final String PARAM_BOARD_MSGID = "uuid"; private static final String PARAM_BOARD_AUTHOR = "author"; private static final String PARAM_BOARD_MESSAGE= "msg"; private static final String PARAM_BOARD_EDITKEY = "key"; private static final long serialVersionUID = 1L; public EditMessageServlet(BulletinBoard _bbs) { bbs = _bbs; } public void doGet(HttpServletRequest _req,HttpServletResponse _res) { String bname = _req.getParameter(PARAM_BOARD_NAME); String uuid = _req.getParameter(PARAM_BOARD_MSGID); try{ PrintWriter pw = _res.getWriter(); pw.write("<html><body><h1>edit message</h1>"); pw.write("<form method='POST'\n"); pw.write("<p>Author : <input type='text' name='author'/>" + "<input type='hidden' name='key' value='"+uuid+"'/>" + "<input type='hidden' name='bname' value='"+bname+"'</p>\n"); pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); pw.write("<p><input type='submit' value='submit'/></p>\n"); pw.write("</body></html>"); pw.flush(); }catch(Exception _e){ _res.setStatus(500); } } public void doPost(HttpServletRequest _req,HttpServletResponse _res) { String boardName = _req.getParameter(PARAM_BOARD_NAME); String author = _req.getParameter(PARAM_BOARD_AUTHOR); String msg = _req.getParameter(PARAM_BOARD_MESSAGE); String key = _req.getParameter(PARAM_BOARD_EDITKEY); String uuid = _req.getParameter(PARAM_BOARD_MSGID); try{ bbs.editMessage(boardName, uuid, author, msg, key); PrintWriter pw = _res.getWriter(); pw.write("successfully written"); pw.flush(); }catch(Exception _e){ _res.setStatus(500); } } }