view src/main/java/jp/ac/u_ryukyu/ie/cr/bbs/browsing/CreateChildServlet.java @ 6:36f0f18ce6a8

change layout import method
author tatsuki
date Tue, 11 Oct 2016 07:15:09 +0900
parents 5acde010c6db
children
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.bbs.browsing;

import org.apache.commons.lang.StringEscapeUtils;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

public class CreateChildServlet extends HttpServlet
{
	private final BrowsingBulletinBoard bbs;
	private static final String PARAM_BOARD_NAME = "bname";
	private static final String PARAM_NODE_PATH = "path";
	private static final String PARAM_NODE_NAME = "nodeName";

	private static final long serialVersionUID = 1L;
	
	public CreateChildServlet(BrowsingBulletinBoard _bbs)
	{
		bbs = _bbs;
	}

	public void doPost(HttpServletRequest _req,HttpServletResponse _res)
	{
		String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME));
		String path = _req.getParameter(PARAM_NODE_PATH);
		String nodeName = _req.getParameter(PARAM_NODE_NAME);
		try{
			PrintWriter pw = _res.getWriter();
			if (!nodeName.equals("")) {
				bbs.createChild(boardName, nodeName, path);
				pw.write("successfully written");
			} else {
				pw.write("faild");
			}
		}catch(Exception _e){
			_res.setStatus(500);
		}
	}
}