Mercurial > hg > Members > shoshi > jungle > bbs
changeset 17:124f90eccaa8
fix filename
author | suruga |
---|---|
date | Sun, 06 Aug 2017 19:25:19 +0900 |
parents | 956042c74e13 |
children | 9722b51dede3 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/browsing/FindNodeServlet.java src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/browsing/FindNodeservlet.java |
diffstat | 2 files changed, 67 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/browsing/FindNodeServlet.java Sun Aug 06 19:25:19 2017 +0900 @@ -0,0 +1,67 @@ +package jp.ac.u_ryukyu.ie.cr.bbs.browsing; + +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.Iterator; + +public class FindNodeServlet extends HttpServlet +{ + private final BrowsingBulletinBoard bbs; + private final String showBoardMessagePath ; + private static final String PARAM_BOARD_NAME = "bname"; + + private static final long serialVersionUID = 1L; + + public FindNodeServlet(BrowsingBulletinBoard _bbs, String _showBoardMessagePath) + { + showBoardMessagePath = _showBoardMessagePath; + bbs = _bbs; + } + + public void doGet(HttpServletRequest _req,HttpServletResponse _res) + { + String bname = _req.getParameter(PARAM_BOARD_NAME); + System.out.println("write"); + + try{ + PrintWriter pw = _res.getWriter(); + pw.write("<html><body><h1>find Node</h1>"); + pw.write("<form method='POST'\n"); + pw.write("<p>" + + "<input type='hidden' name='bname' value='"+bname+"'</p>\n"); + pw.write("<p>key<br/> <input type='textarea' name='key'/> </p>\n"); + pw.write("<p>value<br/> <input type='textarea' name='value'/> </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 bname = _req.getParameter("bname"); + String key = _req.getParameter("key"); + String value = _req.getParameter("value"); + + try{ + Iterator<TreeNode> iterator = bbs.findNode(bname, key, value); + PrintWriter pw = _res.getWriter(); + pw.write("<p>result</p>\n"); + while (iterator.hasNext()) { + TreeNode node = iterator.next(); + String childName = node.getAttributes().getString("NodeName"); + String path = bbs.getNodePath(bname, node).replace("<","").replace(">",""); + pw.write("<p><a href='" + showBoardMessagePath + "?bname=" + bname + "&path=" + path + "'>" +childName + " : path = <" + path + "></a></p>"); + } + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/browsing/FindNodeservlet.java Sun Aug 06 19:18:18 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.bbs.browsing; - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.PrintWriter; -import java.util.Iterator; - -public class FindNodeServlet extends HttpServlet -{ - private final BrowsingBulletinBoard bbs; - private final String showBoardMessagePath ; - private static final String PARAM_BOARD_NAME = "bname"; - - private static final long serialVersionUID = 1L; - - public FindNodeServlet(BrowsingBulletinBoard _bbs, String _showBoardMessagePath) - { - showBoardMessagePath = _showBoardMessagePath; - bbs = _bbs; - } - - public void doGet(HttpServletRequest _req,HttpServletResponse _res) - { - String bname = _req.getParameter(PARAM_BOARD_NAME); - System.out.println("write"); - - try{ - PrintWriter pw = _res.getWriter(); - pw.write("<html><body><h1>find Node</h1>"); - pw.write("<form method='POST'\n"); - pw.write("<p>" + - "<input type='hidden' name='bname' value='"+bname+"'</p>\n"); - pw.write("<p>key<br/> <input type='textarea' name='key'/> </p>\n"); - pw.write("<p>value<br/> <input type='textarea' name='value'/> </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 bname = _req.getParameter("bname"); - String key = _req.getParameter("key"); - String value = _req.getParameter("value"); - - try{ - Iterator<TreeNode> iterator = bbs.findNode(bname, key, value); - PrintWriter pw = _res.getWriter(); - pw.write("<p>result</p>\n"); - while (iterator.hasNext()) { - TreeNode node = iterator.next(); - String childName = node.getAttributes().getString("NodeName"); - String path = bbs.getNodePath(bname, node).replace("<","").replace(">",""); - pw.write("<p><a href='" + showBoardMessagePath + "?bname=" + bname + "&path=" + path + "'>" +childName + " : path = <" + path + "></a></p>"); - } - pw.flush(); - }catch(Exception _e){ - _res.setStatus(500); - } - } -}