Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/main/java/app/bbs/thinks/EditAttributeServlet.java @ 174:e30880a72909
change servlet encode utf-8
author | tatsuki |
---|---|
date | Wed, 30 Jul 2014 17:46:58 +0900 |
parents | d483caeabffc |
children | 066f58e93a14 |
comparison
equal
deleted
inserted
replaced
173:d483caeabffc | 174:e30880a72909 |
---|---|
3 import java.io.PrintWriter; | 3 import java.io.PrintWriter; |
4 | 4 |
5 import javax.servlet.http.HttpServlet; | 5 import javax.servlet.http.HttpServlet; |
6 import javax.servlet.http.HttpServletRequest; | 6 import javax.servlet.http.HttpServletRequest; |
7 import javax.servlet.http.HttpServletResponse; | 7 import javax.servlet.http.HttpServletResponse; |
8 | |
9 import org.apache.commons.lang.StringEscapeUtils; | |
8 | 10 |
9 import app.bbs.NetworkBulletinBoard; | 11 import app.bbs.NetworkBulletinBoard; |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; | 12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; |
11 | 13 |
12 public class EditAttributeServlet extends HttpServlet | 14 public class EditAttributeServlet extends HttpServlet |
24 bbs = _bbs; | 26 bbs = _bbs; |
25 } | 27 } |
26 | 28 |
27 public void doGet(HttpServletRequest _req,HttpServletResponse _res) | 29 public void doGet(HttpServletRequest _req,HttpServletResponse _res) |
28 { | 30 { |
29 String bname = _req.getParameter(PARAM_BOARD_NAME); | 31 String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); |
30 String path = _req.getParameter(PARAM_NODE_ID); | 32 String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); |
31 String id = _req.getParameter(PARAM_NODE_ID); | 33 String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); |
32 | 34 |
33 | 35 |
34 try{ | 36 try{ |
37 _res.setCharacterEncoding("UTF-8"); | |
35 PrintWriter pw = _res.getWriter(); | 38 PrintWriter pw = _res.getWriter(); |
36 pw.write("<html><body><h1>edit message</h1>"); | 39 pw.write("<html><body><h1>edit message</h1>"); |
37 pw.write("<form method='POST'\n"); | 40 pw.write("<form method='POST'\n"); |
38 pw.write("<p><input type='hidden' name='path' value='"+path+"'/>" + | 41 pw.write("<p><input type='hidden' name='path' value='"+path+"'/>" + |
39 "<input type='hidden' name='id' value='"+id+"'/>" + | 42 "<input type='hidden' name='id' value='"+id+"'/>" + |
47 } | 50 } |
48 } | 51 } |
49 | 52 |
50 public void doPost(HttpServletRequest _req,HttpServletResponse _res) | 53 public void doPost(HttpServletRequest _req,HttpServletResponse _res) |
51 { | 54 { |
52 String boardName = _req.getParameter(PARAM_BOARD_NAME); | 55 String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME)); |
53 String msg = _req.getParameter(PARAM_BOARD_MESSAGE); | 56 String msg = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_MESSAGE)); |
54 String path = _req.getParameter("path"); | 57 String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); |
55 String id = _req.getParameter("id"); | 58 String id = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_ID)); |
56 | 59 |
57 try{ | 60 try{ |
58 bbs.editAttribute(boardName, path,id, msg); | 61 bbs.editAttribute(boardName, path,id, msg); |
59 PrintWriter pw = _res.getWriter(); | 62 PrintWriter pw = _res.getWriter(); |
60 pw.write("successfully written"); | 63 pw.write("successfully written"); |