태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

JSP roof test

JSP/Basic 2008/10/15 14:38
==================  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>
top

Trackback Address :: http://www.ssial.com/trackback/116 관련글 쓰기

  1. Burberry Bags 2011/10/13 16:53 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  2. Coach Outlet Online 2011/11/15 12:40 댓글주소 | 수정/삭제 | 댓글

    It's very good!Thank you for sharing it!I like buying handbags of the internet website:http://www.mycoachoutletstoreonline.com

Write a comment