안효원 안효원 2021-08-12
JSPDay2End
@827525dbfb6a86a69fb740017b6b41e3aff1d622
 
202108/.settings/org.eclipse.core.resources.prefs (added)
+++ 202108/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/webapp/0812/index.jsp=UTF-8
 
202108/src/main/java/study/Calc.java (added)
+++ 202108/src/main/java/study/Calc.java
@@ -0,0 +1,28 @@
+package study;
+
+public class Calc {
+
+	int result = 0;
+
+	public Calc(int num1, int num2, String op) {
+
+		if(op.equals("+")){
+			result = num1 + num2;
+		}
+		else if(op.equals("-")){
+			result = num1 - num2;
+		}
+		else if(op.equals("*")){
+			result = num1 * num2;
+		}
+		else {
+			result = num1 / num2;
+		}
+		
+		
+	}
+	public int getResult() {
+		return result;
+	}
+
+}(No newline at end of file)
202108/src/main/java/study/CalcServlet.java (Renamed from 202108/src/main/java/TestServlet.java)
--- 202108/src/main/java/TestServlet.java
+++ 202108/src/main/java/study/CalcServlet.java
@@ -1,4 +1,4 @@
-
+package study;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -9,17 +9,19 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.jasper.tagplugins.jstl.core.Out;
+
 /**
- * Servlet implementation class TestServlet
+ * Servlet implementation class CalcServlet
  */
-@WebServlet("/TestServlet")
-public class TestServlet extends HttpServlet {
+@WebServlet("/CalcServlet")
+public class CalcServlet extends HttpServlet {
 	private static final long serialVersionUID = 1L;
        
     /**
      * @see HttpServlet#HttpServlet()
      */
-    public TestServlet() {
+    public CalcServlet() {
         super();
         // TODO Auto-generated constructor stub
     }
@@ -28,21 +30,36 @@
 	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 	 */
 	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-		response.setContentType("text/html;charset-utf-8");
-		PrintWriter out = response.getWriter();
 		
-		out.println("<html>");
-		out.println("<head><title>This is Servlet Page</title></head>");
-		out.println("<body><h2>HelloWorld!</h2></body>");
-		out.println("</html>");
+		doPost(request, response);
+		
 	}
 
 	/**
 	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 	 */
 	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-		// TODO Auto-generated method stub
-		doGet(request, response);
+
+		response.setContentType("text/html;charset-utf-8");
+		
+		int num1 = Integer.parseInt(request.getParameter("num1"));
+		int num2 = Integer.parseInt(request.getParameter("num2"));
+		String op = request.getParameter("op");
+		
+		PrintWriter out = response.getWriter();
+		
+		Calc calc = new Calc(num1, num2, op);
+		int result = calc.getResult();
+		
+		out.println("<html>");
+		out.println("<head><title>Calculator</title></head>");
+		out.println("<body>");
+		out.println("<h2>Calculating Result</h2>");
+		out.print(num1 + op + num2 + "=" + result);
+		out.println("</body>");
+		out.println("</html>");
+		
 	}
 
 }
+
 
202108/src/main/webapp/0812/3.html (added)
+++ 202108/src/main/webapp/0812/3.html
@@ -0,0 +1,112 @@
+<!doctype html>
+<html lang="ko">
+<head>
+    <meta charset="UTF-8">
+    <style>
+        * {margin: 0; padding: 0; box-sizing: border-box; color: #666666;}
+        body {background: no-repeat url("http://web.miri.kr/example/images/bg.jpg")fixed; background-size: cover;}
+        #container {width: 1030px; margin: 0 auto;background-color: white}
+        #top {background-color: #666666;}
+        #top ul li {display: inline-block; vertical-align: middle; margin-right: 40px;}
+        #top ul li a {text-decoration: none; color: white; font-weight: 600; font-size: large;}
+        #top ul li a:hover {color: black;}
+        #second {background: url("http://web.miri.kr/example/images/main1.jpg"); width: 1030px; height: 500px;}
+        #article {width: 1030px; height: 500px;}
+        #left {width: 70%; height: 500px; float: left;}
+        #right {width: 30%; height: 500px; float: left;}
+        #leftTop {height: 50%;}
+        #leftBottom {height: 50%;}
+        #leftTopLeft {width: 50%; height: 100%; float: left;}
+        #leftTopRight {width: 50%; height: 100%; float: left;}
+        #leftBottomLeft {width: 50%; height: 100%; float: left;}
+        #leftBottomRight {width: 50%; height: 100%; float: left;}
+        #img2 {width: 300px; height: 210px; margin-left: 25px; margin-top: 15px;}
+        #lorem1 {font-size: 25px;}
+        #lorem2 {font-size: 20px; color: #985d6a;}
+        #caption1 {margin-left: 25px;}
+        #this {margin-left: 10px; margin-top: 20px;}
+        #img3 {width: 300px; height: 210px; margin-left: 25px; margin-top: 15px;}
+        #rightTop {width: 100%; height: 50%;}
+        #rightBottom {width: 100%; height: 50%;}
+        #rightTop ul {margin-top: 10px;}
+        #rightTop ul li {list-style: none; margin-bottom: 20px;}
+        #rightTop ul li:hover {background-color: #aeaca8;}
+        #rightTop ul li a {text-decoration: none; color: #985d6a;}
+        #walking {font-size: 30px;}
+        #this0 {margin-top: 10px;}
+        #contact {font-size: 30px; color: #985d6a;}
+        #footer {background-color: #666666; color: white;}
+    </style>
+</head>
+<body>
+    <div id="container">
+        <div id="top">
+            <ul>
+                <li><a href="#"><img id="logo" src="http://www.aiit.or.kr/images/logo.png"></a></li>
+                <li><a href="#">Company</a></li>
+                <li><a href="#">Product</a></li>
+                <li><a href="#">Service</a></li>
+                <li><a href="#">Community</a></li>
+                <li><a href="#">Contact</a></li>
+            </ul>
+        </div>
+        <div id="second">
+<!--            손 그림-->
+        </div>
+        <div id="article">
+            <div id="left">
+                <div id="leftTop">
+                    <div id="leftTopLeft">
+                        <img id="img2" src="http://web.miri.kr/example/images/image1.jpg">
+                        <p id="caption1">그림[1]</p>
+                    </div>
+                    <div id="leftTopRight">
+                        <p id="this0">
+                            <span id="lorem1">Lorem ipsum.</span><br>
+                            <span id="lorem2">Lorem ipsum dolor sit amet.</span><br><br>
+                            <span id="lorem3">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A dicta doloremque ea eaque eligendi excepturi exercitationem explicabo saepe sit. Consequatur delectus doloribus in magnam natus nesciunt nostrum odio soluta voluptatem!</span>
+                        </p>
+                    </div>
+                </div>
+                <div id="leftBottom">
+                    <div id="leftBottomLeft">
+                        <p id="this">
+                            <span id="lorem1">Lorem ipsum.</span><br>
+                            <span id="lorem2">Lorem ipsum dolor sit amet.</span><br><br>
+                            <span id="lorem3">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A dicta doloremque ea eaque eligendi excepturi exercitationem explicabo saepe sit. Consequatur delectus doloribus in magnam natus nesciunt nostrum odio soluta voluptatem!</span>
+                        </p>
+                    </div>
+                    <div id="leftBottomRight">
+                        <img id="img3" src="http://web.miri.kr/example/images/image2.jpg">
+                        <p id="caption1">그림[2]</p>
+                    </div>
+                </div>
+            </div>
+            <div id="right">
+                <div id="rightTop">
+                    <ul>
+                        <li><a id="walking" href="">Walking Exersise</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                    </ul>
+                </div>
+                <div id="rightBottom">
+                    <p id="lastText">
+                        <span id="contact">Contact Us</span><br><br>
+                        <span>Gwangju Industrial Tools</span><br>
+                        <span>Circulating Center,</span><br>
+                        <span>Maewol-dong, Seo-gu,</span><br>
+                        <span>Gwanju, korea</span><br>
+                        <span>062-000-1111</span>
+                    </p>
+                </div>
+            </div>
+        </div>
+        <div id="footer">
+            Copyright&copy;2019한국정보통신교육원 All rights reserved.
+        </div>
+    </div>
+</body>
+</html>(No newline at end of file)
 
202108/src/main/webapp/0812/article.jsp (added)
+++ 202108/src/main/webapp/0812/article.jsp
@@ -0,0 +1,56 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+		<div id="second">
+			<!--손 그림-->
+        </div>
+        <div id="article">
+            <div id="left">
+                <div id="leftTop">
+                    <div id="leftTopLeft">
+                        <img id="img2" src="http://web.miri.kr/example/images/image1.jpg">
+                        <p id="caption1">그림[1]</p>
+                    </div>
+                    <div id="leftTopRight">
+                        <p id="this0">
+                            <span id="lorem1">Lorem ipsum.</span><br>
+                            <span id="lorem2">Lorem ipsum dolor sit amet.</span><br><br>
+                            <span id="lorem3">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A dicta doloremque ea eaque eligendi excepturi exercitationem explicabo saepe sit. Consequatur delectus doloribus in magnam natus nesciunt nostrum odio soluta voluptatem!</span>
+                        </p>
+                    </div>
+                </div>
+                <div id="leftBottom">
+                    <div id="leftBottomLeft">
+                        <p id="this">
+                            <span id="lorem1">Lorem ipsum.</span><br>
+                            <span id="lorem2">Lorem ipsum dolor sit amet.</span><br><br>
+                            <span id="lorem3">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A dicta doloremque ea eaque eligendi excepturi exercitationem explicabo saepe sit. Consequatur delectus doloribus in magnam natus nesciunt nostrum odio soluta voluptatem!</span>
+                        </p>
+                    </div>
+                    <div id="leftBottomRight">
+                        <img id="img3" src="http://web.miri.kr/example/images/image2.jpg">
+                        <p id="caption1">그림[2]</p>
+                    </div>
+                </div>
+            </div>
+            <div id="right">
+                <div id="rightTop">
+                    <ul>
+                        <li><a id="walking" href="">Walking Exersise</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                        <li><a href="">Lorem ipsum dolor sit amet.</a></li>
+                    </ul>
+                </div>
+                <div id="rightBottom">
+                    <p id="lastText">
+                        <span id="contact">Contact Us</span><br><br>
+                        <span>Gwangju Industrial Tools</span><br>
+                        <span>Circulating Center,</span><br>
+                        <span>Maewol-dong, Seo-gu,</span><br>
+                        <span>Gwanju, korea</span><br>
+                        <span>062-000-1111</span>
+                    </p>
+                </div>
+            </div>
+        </div>(No newline at end of file)
 
202108/src/main/webapp/0812/calc.html (added)
+++ 202108/src/main/webapp/0812/calc.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Calculator</title>
+</head>
+<body>
+	<form action="/202108//CalcServlet" method="post">
+		<input type="text" name="num1">
+		<select name="op">
+			<option value="+">+</option>
+			<option value="-">-</option>
+			<option value="*">*</option>
+			<option value="/">/</option>
+		</select>
+		<input type="text" name="num2">
+		<input type="submit" value="Run">
+	</form>
+</body>
+</html>(No newline at end of file)
 
202108/src/main/webapp/0812/error.jsp (added)
+++ 202108/src/main/webapp/0812/error.jsp
@@ -0,0 +1,17 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8" isErrorPage="true"%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Sorry Error</title>
+</head>
+<body>
+	<h2>error!!</h2>
+	<hr />
+	Call Web master please <br />
+	It will be fix soon! 
+	<hr />
+	<%= exception %>
+</body>
+</html>(No newline at end of file)
 
202108/src/main/webapp/0812/error_test.jsp (added)
+++ 202108/src/main/webapp/0812/error_test.jsp
@@ -0,0 +1,16 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8" errorPage="error.jsp"%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+	<h2>This is error test Page</h2>
+	<%
+		String a = "test";
+		int i = Integer.parseInt(a);
+	%>
+</body>
+</html>(No newline at end of file)
 
202108/src/main/webapp/0812/include_test.jsp (added)
+++ 202108/src/main/webapp/0812/include_test.jsp
@@ -0,0 +1,19 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Main Page</title>
+</head>
+<body>
+	<h2>This is main page</h2>
+	<hr>
+	<h2>News Page</h2>
+	<%@ include file="news.jsp" %>
+	<hr />
+	<h2>Shopping Page</h2>
+	<%@ include file="shopping.jsp" %>
+	<h2>End main page</h2>
+</body>
+</html>(No newline at end of file)
 
202108/src/main/webapp/0812/index.jsp (added)
+++ 202108/src/main/webapp/0812/index.jsp
@@ -0,0 +1,49 @@
+<!doctype html>
+<html lang="ko">
+<head>
+    <meta charset="UTF-8">
+    <style>
+        * {margin: 0; padding: 0; box-sizing: border-box; color: #666666;}
+        body {background: no-repeat url("http://web.miri.kr/example/images/bg.jpg")fixed; background-size: cover;}
+        #container {width: 1030px; margin: 0 auto;background-color: white}
+        #top {background-color: #666666;}
+        #top ul li {display: inline-block; vertical-align: middle; margin-right: 40px;}
+        #top ul li a {text-decoration: none; color: white; font-weight: 600; font-size: large;}
+        #top ul li a:hover {color: black;}
+        #second {background: url("http://web.miri.kr/example/images/main1.jpg"); width: 1030px; height: 500px;}
+        #article {width: 1030px; height: 500px;}
+        #left {width: 70%; height: 500px; float: left;}
+        #right {width: 30%; height: 500px; float: left;}
+        #leftTop {height: 50%;}
+        #leftBottom {height: 50%;}
+        #leftTopLeft {width: 50%; height: 100%; float: left;}
+        #leftTopRight {width: 50%; height: 100%; float: left;}
+        #leftBottomLeft {width: 50%; height: 100%; float: left;}
+        #leftBottomRight {width: 50%; height: 100%; float: left;}
+        #img2 {width: 300px; height: 210px; margin-left: 25px; margin-top: 15px;}
+        #lorem1 {font-size: 25px;}
+        #lorem2 {font-size: 20px; color: #985d6a;}
+        #caption1 {margin-left: 25px;}
+        #this {margin-left: 10px; margin-top: 20px;}
+        #img3 {width: 300px; height: 210px; margin-left: 25px; margin-top: 15px;}
+        #rightTop {width: 100%; height: 50%;}
+        #rightBottom {width: 100%; height: 50%;}
+        #rightTop ul {margin-top: 10px;}
+        #rightTop ul li {list-style: none; margin-bottom: 20px;}
+        #rightTop ul li:hover {background-color: #aeaca8;}
+        #rightTop ul li a {text-decoration: none; color: #985d6a;}
+        #walking {font-size: 30px;}
+        #this0 {margin-top: 10px;}
+        #contact {font-size: 30px; color: #985d6a;}
+        #footer {background-color: #666666; color: white; padding: 10px 0 10px 5px;}
+    </style>
+</head>
+<body>
+    <div id="container">
+    	<!-- 스크립트릿  -->
+        <%@ include file="top.jsp" %>
+        <%@ include file="article.jsp" %>
+        <%@ include file="footer.jsp" %>
+    </div>
+</body>
+</html>(No newline at end of file)
 
202108/src/main/webapp/0812/news.jsp (added)
+++ 202108/src/main/webapp/0812/news.jsp
@@ -0,0 +1,4 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+    
+	[게임] [쇼핑] [시사](No newline at end of file)
 
202108/src/main/webapp/0812/shopping.jsp (added)
+++ 202108/src/main/webapp/0812/shopping.jsp
@@ -0,0 +1,9 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+
+    	<ul>
+    		<li>상의</li>
+    		<li>하의</li>
+    		<li>아우터</li>
+    		<li>악세사리</li>
+    	</ul>(No newline at end of file)
 
202108/src/main/webapp/0812/top.jsp (added)
+++ 202108/src/main/webapp/0812/top.jsp
@@ -0,0 +1,12 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+		<div id="top">
+            <ul>
+                <li><a href="#"><img id="logo" src="http://www.aiit.or.kr/images/logo.png"></a></li>
+                <li><a href="#">Company</a></li>
+                <li><a href="#">Product</a></li>
+                <li><a href="#">Service</a></li>
+                <li><a href="#">Community</a></li>
+                <li><a href="#">Contact</a></li>
+            </ul>
+        </div>(No newline at end of file)
Add a comment
List