package com.wxpn.tutorial.ec.servlet;

import java.io.IOException;
import java.util.Collection;

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

import com.wxpn.tutorial.ec.bean.ECBookMgr;

/**
 * Servlet implementation class for Servlet: UserListServlet
 */
public class NewBookServlet extends javax.servlet.http.HttpServlet implements
		javax.servlet.Servlet {
	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public NewBookServlet() {
		super();
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setHeader("Pragma","No-cache");
		response.setHeader("Cache-Control","no-cache");
		response.setDateHeader("Expires", 0);
		
		ECBookMgr mgr = new ECBookMgr();
		Collection c = mgr.getAll(10, 1, "");
		request.setAttribute("c", c);
		try {
			request.getRequestDispatcher("/book_store/new_goods.jsp").forward(
					request, response);
		} catch (Throwable t) {
			getServletContext().log(t.getMessage());
		}
	}
}