1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
package fr.gui.servlet;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import fr.gui.bean.Page;
import fr.gui.dao.DaoFactory;
import fr.gui.dao.IPageDao;
import fr.gui.dao.PageDaoImpl;
/**
* Servlet implementation class AdminServlet
*/
@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
IPageDao pageDao = new PageDaoImpl();
/**
* Default constructor.
*/
public AdminServlet() {
// TODO Auto-generated constructor stub
}
/**
* @see Servlet#init(ServletConfig)
*/
public void init() throws ServletException {
DaoFactory.getInstance();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
/* response.getWriter().append("Served at: ").append(request.getContextPath());
Page page = new Page();
page.setId(1);
request.setAttribute("page", pageDao.getPage(page));*/
this.getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String text1 = null;
text1 = (String) request.getParameter("editor1");
Page page = new Page();
page.setId(1);
page.setTexte(text1);
pageDao.modifier(page);
System.out.println("text1 : "+text1);
doGet(request, response);
}
} |
Partager