================== testForm.jsp ============================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
숫자를 입력하세요! <br>력한 숫자가 10보다 작거나 큰가요? 전송 받는 페이지에서 알 수 있습니다..
<form method="post" action="testProc.jsp" name="insertForm"><input name="num" type="text"><input type="submit" name="submit" value="전송"></form>
</body>
</html>
================== testProc.jsp (1) ============================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("euc-kr");
String number = "0123456789";
boolean check = true;
if (request.getParameter("num")!=""){
String tmpNum = request.getParameter("num");
for (int i = 0; i < tmpNum.length(); i++){
// tmpNum.charAt(i)
if(tmpNum.charAt(i)<48 || tmpNum.charAt(i)>58){
check = false;
break;
}
}
if (check){
int num = Integer.parseInt(tmpNum);
if (num<=10){
out.println("입력한 숫자 " +num+ "은(는) 10보다 작거나 같습니다.");
}else{
out.println("입력한 숫자 " +num+ "은(는) 10보다 큽니다.");
}
}else{
out.println(" 숫자를 입력하지 않았습니다." + tmpNum + "숫자가 아닙니다.");
}
}else{
%>
<%="숫자를 입력해 주세요!" %>
<%
}
%>
<br>
<br>
<a href="testForm.jsp">처음으로 돌아가기</a>
</body>
</html>
================== testProc.jsp (2) ============================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("euc-kr");
String number = "0123456789";
boolean check = true;
if (request.getParameter("num")!=""){
String tmpNum = request.getParameter("num");
next:{
for (int i = 0; i < tmpNum.length(); i++){
for (int j = 0; j<number.length(); j++){
// tmpNum.charAt(i)
if(tmpNum.charAt(i)!= number.charAt(i)){
check = false;
break next;
}
}
}
}
if (check){
int num = Integer.parseInt(tmpNum);
if (num<=10){
out.println("입력한 숫자 " +num+ "은(는) 10보다 작거나 같습니다.");
}else{
out.println("입력한 숫자 " +num+ "은(는) 10보다 큽니다.");
}
}else{
out.println(" 숫자를 입력하지 않았습니다." + tmpNum + "숫자가 아닙니다.");
}
}else{
%>
<%="숫자를 입력해 주세요!" %>
<%
}
%>
<br><br>
<a href="testForm.jsp">처음으로 돌아가기</a>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
숫자를 입력하세요! <br>력한 숫자가 10보다 작거나 큰가요? 전송 받는 페이지에서 알 수 있습니다..
<form method="post" action="testProc.jsp" name="insertForm"><input name="num" type="text"><input type="submit" name="submit" value="전송"></form>
</body>
</html>
================== testProc.jsp (1) ============================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("euc-kr");
String number = "0123456789";
boolean check = true;
if (request.getParameter("num")!=""){
String tmpNum = request.getParameter("num");
for (int i = 0; i < tmpNum.length(); i++){
// tmpNum.charAt(i)
if(tmpNum.charAt(i)<48 || tmpNum.charAt(i)>58){
check = false;
break;
}
}
if (check){
int num = Integer.parseInt(tmpNum);
if (num<=10){
out.println("입력한 숫자 " +num+ "은(는) 10보다 작거나 같습니다.");
}else{
out.println("입력한 숫자 " +num+ "은(는) 10보다 큽니다.");
}
}else{
out.println(" 숫자를 입력하지 않았습니다." + tmpNum + "숫자가 아닙니다.");
}
}else{
%>
<%="숫자를 입력해 주세요!" %>
<%
}
%>
<br>
<br>
<a href="testForm.jsp">처음으로 돌아가기</a>
</body>
</html>
================== testProc.jsp (2) ============================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("euc-kr");
String number = "0123456789";
boolean check = true;
if (request.getParameter("num")!=""){
String tmpNum = request.getParameter("num");
next:{
for (int i = 0; i < tmpNum.length(); i++){
for (int j = 0; j<number.length(); j++){
// tmpNum.charAt(i)
if(tmpNum.charAt(i)!= number.charAt(i)){
check = false;
break next;
}
}
}
}
if (check){
int num = Integer.parseInt(tmpNum);
if (num<=10){
out.println("입력한 숫자 " +num+ "은(는) 10보다 작거나 같습니다.");
}else{
out.println("입력한 숫자 " +num+ "은(는) 10보다 큽니다.");
}
}else{
out.println(" 숫자를 입력하지 않았습니다." + tmpNum + "숫자가 아닙니다.");
}
}else{
%>
<%="숫자를 입력해 주세요!" %>
<%
}
%>
<br><br>
<a href="testForm.jsp">처음으로 돌아가기</a>
</body>
</html>



