package twitter;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Sing extends HttpServlet {
	TwitterDao twitterDao = new TwitterDao();

	private static final String param = "status";
	private static final String indexJsp = "index.jsp";

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		String status = req.getParameter(param);
		Date date = new Date();
		Twitter t = new Twitter(status, date);
		twitterDao.put(t);

		resp.sendRedirect(indexJsp);
	}
}
