package명 : step01.view, Servlet 클래스명 : FailView 파일 생성
package step01.view;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/fail")
public class FailView extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
process(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
process(request,response);
}
protected void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// client 브라우저에 "무효한 id입니다" 출력
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("무효한 id입니다");
}
}
login.html에서 id : tester11로 입력하면 (tester제외 다른 id는 fail)
무효한 id입니다 출력