⑨ 작성자로 검색하는 servlet 만들기
package guestbook.controller;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
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 guestbook.GuestBookService;
import guestbook.GuestBookVo;
/**
* Servlet implementation class getbywriter
*/
@WebServlet("/guest/getbywriter")
public class getbywriter extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public getbywriter() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("euc-kr");
response.setCharacterEncoding("euc-kr");
response.setContentType("text/html; charset = EUC-KR");
String writer = request.getParameter("writer");
GuestBookService service = new GuestBookService();
ArrayList<GuestBookVo> list = service.getByWriter(writer);
request.setAttribute("list", list);
RequestDispatcher dis = request.getRequestDispatcher("/guestbook/listAll.jsp");
dis.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
'MVC > jsp & servlet' 카테고리의 다른 글
[jsp와 servlet] 익명 방명록 만들기 ⑦ 글 번호 클릭하여 상세 보기 (0) | 2023.03.29 |
---|---|
[jsp와 servlet] 익명 방명록 만들기 ⑥ 삭제 구현 하기 (0) | 2023.03.29 |
[jsp와 servlet] 익명 방명록 만들기 ④ 글 목록 만들기 (0) | 2023.03.29 |
[jsp와 servlet] 익명 방명록 만들기 ③ 글 작성 기능 구현 (0) | 2023.03.29 |
[jsp와 servlet] 익명 방명록 만들기 ② view 메인 페이지 만들기 (0) | 2023.03.29 |