Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Everything has an expiration date

[JSP & Servlet] 20231208 [프로그램소스 (JSP → JSP)] - SendAndReceive06 본문

[JSP & Servlet]/Program source (JSP & Servlet)

[JSP & Servlet] 20231208 [프로그램소스 (JSP → JSP)] - SendAndReceive06

Jelly-fish 2023. 12. 10. 17:14

 

WebApp07

 


01
SendAndReceive06


 

 

SendAndRecieve06.jsp

 

<%@ page contentType="text/html; charset=UTF-8"%>
<%
	// 내가 보낸 것을 다시 받자!!
	
	// 이전 페이지(SendAndReceive06.jsp → 자기 자신 페이지)로부터 넘어온 데이터 수신
	// → userInput
	
	request.setCharacterEncoding("UTF-8");

	String temp = "";
	
	temp = request.getParameter("userInput");
	
	
	// 첫 실행시, temp에 아무런 값이 없어서 null이라면...
	// "없음" 문자열 대입
	if (temp == null)
		temp = "없음";

%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SendAndReceive06/jsp</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<style type="text/css">
@font-face {
			    font-family: 'TheJamsil5Bold';
			    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2302_01@1.0/TheJamsil5Bold.woff2') format('woff2');
			    font-weight: 700;
			    font-style: normal;
			}
			
			* { font-family: 'TheJamsil5Bold'; margin: 10pt; text-align: center;}
			button {width: 30%; height: 30pt; margin: 10pt; border: none; background-color: #E0FFDF;}
			div {border-radius: 20pt; background-color: #f3ffe8; padding: 5pt;}

</style>
</head>
<body>

<div>
	<h1>데이터 송수신 실습 06</h1>
	<hr>
</div>

<div>
	
	<!--
	<form action="Test999.jsp" method="post">
		입력
		<input type="text" id="userInput" name="userInput" class="txt">
		<br>
		
		<button type="submit" class="btn control">테스트</button>
		<button type="reset" class="btn control">취소</button>
	</form> -->
	
	
	<!-- 데이터 송수신 대상 : 자기자신(SendAndReceive06) -->
	
<!--
	 [action 없음, method=post 방식]
	<form action="" method="post">
		입력
		<input type="text" id="userInput" name="userInput" class="txt">
		<br>
		
		<button type="submit" class="btn control">테스트</button>
		<button type="reset" class="btn control">취소</button>
	</form>
 -->

<!-- [action 없음, method=get 방식]
	<form action="" method="get">
		입력
		<input type="text" id="userInput" name="userInput" class="txt">
		<br>
		
		<button type="submit" class="btn control">테스트</button>
		<button type="reset" class="btn control">취소</button>
	</form>
-->
	

<!-- [action 지우기] 	
	<form  method="get">
		입력
		<input type="text" id="userInput" name="userInput" class="txt">
		<br>
		
		<button type="submit" class="btn control">테스트</button>
		<button type="reset" class="btn control">취소</button>
	</form>
 -->

<!-- action 생략 : 자기자신
     method 생략 : GET 방식
 -->
	<form>
		입력
		<input type="text" id="userInput" name="userInput" class="txt">
		<br>
		
		<button type="submit" class="btn control">테스트</button>
		<button type="reset" class="btn control">취소</button>
	</form>
	
	
	<!-- check~!!! -->
	<!-- ※ form 의 action 속성을 『action=""』 와 같이 구성하거나
	        action 속성을 생략하여 『<form method="post">』와 같이 구성하게 되면
	        페이지 요청 및 데이터 전송에 대한 수신지 페이지는 자기 자신이 된다.	 
	-->
</div>

<!--
	ⓐ
	========================
	[처음 페이지 열었을 때]
	("없음" 대입 전)
	========================
	수신된 데이터 확인
	→ null
	========================
	
	ⓑ
	========================
	[입력 창에 값 넣었을 때]
	========================
	수신된 데이터 확인
	→ 안녕하세요
	========================
  -->

<div>
	<h2>수신된 데이터 확인</h2>
	<h3>→ <%=temp %></h3>
</div>










</body>
</html>