
1. Dynamic web project 생성
폴더이름은 WebContent/WEB-INF/classes 로 써준다.
next =>
디렉토리이름 WebContent 라고 작성. 그리고 피니쉬!!



제일먼저 web.xml 파일을 열어준다. 웰컴파일중 index.jsp 라는 이름을 복사한뒤
WebContent 폴더 아래에 index.jsp 라는 이름의 jsp file을 만들어준다
index.jsp 파일의 body 에 입력받을 점수와 제출할 수 있는 버튼을 만들어준다.
먼저, action을 줘야하기 때문에 폼 태그로 감싼다.
<form action="/1_test/test.do"> method = "get">
<h4>당신의 점수를 입력해주세요</h4>
국어점수 : <input type="text" name = "korean"> <br>
수학점수 : <input type="text" name ="Math"> <br>
<input type="submit" value="점수 입력">
</form>
2. 서블렛 생성
src 폴더에서 com.kh.controller 패키지를 생성해준다.
controller에 서블릿을 생성 !
class name 은 자유롭게 설정하고
next =>
url mappings 는 더블클릭 하고 /test.do 로 변경해준다.
서블릿에서 get 방식을 사용시
doGet 아래 지우고 조건문을 써준다.

int korean = Integer.parseInt(request.getParameter("korean"));
int Math = Integer.parseInt(request.getParameter("Math"));
request.setAttribute("korean", korean);
request.setAttribute("Math", Math);
if(korean >= 60 && Math >= 60) {
RequestDispatcher view1 = request.getRequestDispatcher("views/pass.jsp");
view1.foward(request, response);
}else {
RequestDispatcher view2 = request.getRequesetDispatcher("views/fail.jps");
}
3. 응답화면 만들기
views 폴더의 내부에
합격과 불합격 2개의 응답화면을 만들어 준다.
pass.jsp
fail.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
int korean = (int)request.getAttribute("korean");
int math = (int)request.getAttribute("math");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1> <합격입니다> </h1>
당신의 국어점수 : <%= korean %>점 <br>
당신의 수학점수 : <%= math %>점 <br>
<h4>합격입니다</h4>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
int korean = (int)request.getAttribute("korean");
int math = (int)request.getAttribute("math");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>< 불합격입니다 ></h1>
당신의 국어점수 : <%= korean %>점 <br>
당신의 수학점수 : <%= math %>점 <br>
<h4> 불합격입니다.</h4>
</body>
</html>