Notice
Recent Posts
Recent Comments
Link
Coding Note
[JSP] 학점 출력하기! 본문
학점 출력하기!!
구현
코드
1. HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>시험점수입력</title>
</head>
<body>
<form method="get" action="scoreTest.jsp">
시험점수 : <input type="text" name="score"><br>
<input type="submit" value="변환하기">
</form>
</body>
</html>
2. JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
int score = Integer.parseInt(request.getParameter("score"));
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>학점출력</title>
</head>
<body>
<h1>시험점수 : <%=score %></h1><br>
<%
if(score>=90) {
%>
<h1>A학점입니다.</h1>
<%
}
else if(score>=80 && score<90) {
%>
<h1>B학점입니다.</h1>
<%
}
else if(score>=70 && score<80) {
%>
<h1>C학점입니다.</h1>
<%
}
else if(score>=60 && score<70) {
%>
<h1>D학점입니다.</h1>
<%
}
else {
%>
<h1>F학점입니다.</h1>
<%
}
%>
<br>
<a href="scoreTest.html">시험점수 입력</a>
</body>
</html>
'Web > Jsp' 카테고리의 다른 글
[JSP] ForwardActionTag 로그인 - 환영합니다! (0) | 2022.02.05 |
---|---|
[JSP] Cookie 활용한 아이디 정보 저장하기 (0) | 2022.02.04 |
[JSP] 계산하기 (0) | 2022.02.02 |
[JSP] LocaleDate 함수 사용하기+Include (0) | 2022.02.01 |
[JSP] 오늘 날짜 출력하기 (0) | 2022.02.01 |
Comments