jsp

2022_11_29 JSP HTTP Request Post방식

0304호 2022. 11. 29.

HTTP Request Post방식
 - 서버에 데이터를 전송하는 용도
 - 데이터가 url에 묻어가지않고 정송객체의 메세지 바디를 통해 전달함
 - 보안성이 강함
 - 반드시 html form태그가 필요함
 - 데이터 양의 제한이 없음
 - request.setCharacterEncoding("utf-9");로 인코딩함

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>post1번예시</title>
</head>
<body>

	<form action="req_post02.jsp" method="post">
		아이디 : <input type="text" name="id"><br>
		이메일 : <input type="email" name="email"><br>
		<input type="submit" value="확인"><br>
	</form>

</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!--  인코딩을 request.setCharacterEncoding("UTF-8"); 사용해서함 -->
   	<%
   	request.setCharacterEncoding("UTF-8");		//한글을 utf-8로 인코딩 처리
   	String id = request.getParameter("id");
   	String email = request.getParameter("email");
   	
   	%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>post1번예시</title>
</head>
<body>
	
	<%=id %><br>
	<%=email %>

</body>
</html>

댓글