1. 아래를 프로그래밍 하시오.
단을 보내기 버튼을 누르면 해당 단을 출력
<!-- code1 --> <!-- .\WebContent\gugudan.html --> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>gugudan</title> </head> <body> <form action = "gugudan.jsp" method = "post"> <h1>단을 입력하시오</h1> <input type ="number" name="dan" min="1" max="9"> <input type = "submit" value = "보내기"> </form> </body> </html>
<!-- code2 --> <!-- .\WebContent\gugudan.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>gugudan</title> </head> <body> <% final int DAN_MIN = 1; final int DAN_MAX = 9; StringBuilder print = new StringBuilder(); String danStr = request.getParameter("dan"); int dan = Integer.parseInt(danStr); for (int i = DAN_MIN; i <= DAN_MAX; i++) { print.append(dan); print.append("x"); print.append(i); print.append("="); print.append(dan * i); %> <%=print.toString()%> <% print.setLength(0); %> <br> <% }; %> <a href="gugudan.html">돌아가기</a> </body> </html>
2. 아래를 프로그래밍 하시오.
<!-- code1 --> <!-- .\WebContent\gugudan.html --> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>gugudan</title> </head> <body> <form action = "gugudan.jsp" method = "post"> <h1>단을 입력하시오</h1> <input type="radio" name="dan" value="1" id="dan1"> <label for="dan1">1단</label> <input type="radio" name="dan" value="2" id="dan2"> <label for="dan2">2단</label> <input type="radio" name="dan" value="3" id="dan3"> <label for="dan3">3단</label> <input type="radio" name="dan" value="4" id="dan4"> <label for="dan4">4단</label> <input type="radio" name="dan" value="5" id="dan5"> <label for="dan5">5단</label> <input type="radio" name="dan" value="6" id="dan6"> <label for="dan6">6단</label> <input type="radio" name="dan" value="7" id="dan7"> <label for="dan7">7단</label> <input type="radio" name="dan" value="8" id="dan8"> <label for="dan8">8단</label> <input type="radio" name="dan" value="9" id="dan9"> <label for="dan9">9단</label> <input type = "submit" value = "보내기"> </form> </body> </html>
<!-- code2 --> <!-- .\WebContent\gugudan.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>gugudan</title> </head> <body> <% final int DAN_MIN = 1; final int DAN_MAX = 9; StringBuilder print = new StringBuilder(); String danStr = request.getParameter("dan"); int dan = Integer.parseInt(danStr); for (int i = DAN_MIN; i <= DAN_MAX; i++) { print.append(dan); print.append("x"); print.append(i); print.append("="); print.append(dan * i); %> <%=print.toString()%> <% print.setLength(0); %> <br> <% }; %> <a href="gugudan.html">돌아가기</a> </body> </html>