- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="EUC-KR">
- </head>
- <body>
- <!--
- 3.Three.java - model2
- -->
- <form method="post" action="/Three">
- 단을 입력하세요
- <input type="text" name="dan">
- <input type="submit">
- </form>
- </body>
- </html>
2. GuGu.java
- package com.example;
- public class GuGu {
- String output="";
- for(int i=1; i<10; i++){
- output += dan+"*"+i+"="+(dan*i)+"<br>";
- }
- return output;
- }
- }
3. Three.java
- package com.example;
- import java.io.IOException;
- import javax.servlet.RequestDispatcher;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- @WebServlet("/Three")
- public class Three extends HttpServlet {
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- GuGu gugu = new GuGu();
- // request + alpha
- request.setAttribute("answer", str);
- RequestDispatcher rd = request.getRequestDispatcher("/three_view.jsp");
- rd.forward(request, response);
- }
- }
4. three_view.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>
- <%
- %>
- <%=str%>
- </body>
- </html>
댓글 없음:
댓글 쓰기