본문 바로가기

JSP 웹 프로그래밍/수업내용

[JSP 웹 프로그래밍] 내장 객체 - 예제

 

request.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Implicit Object</title>
</head>
<body>
	<!-- 
		form 페이지 
		요청경로 : process.jsp
		요청 파라미터 : name=개똥이(입력 양식 이름 = 값)
		요청 방식 : post
	 -->
	 <form action="process.jsp" method="get">
	 	<!-- 폼 데이터 -->
	 	<p>
	 				<!-- required : 필수 입력  -->
	 		이름 : <input type="text" name="name" placeholder="이름" required/>
	 		<input type="submit" value="전송" />
	 	</p>
	 </form>
</body>
</html>

 

 

 

process.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
	<!-- 
		요청경로 : process.jsp
		요청 파라미터 : name=개똥이(입력 양식 이름 = 값)
		요청 방식 : post
	 -->		
	 <%
	 	//내장 객체.메소드(인코딩)
	 	request.setCharacterEncoding("UTF-8");//한글 처리 
	 	//      변수 		내장객체	폼 페이지에서 입력된 데이터를 전달하는 요청 파라미터 값을 가져옴 
	 	String name = request.getParameter("name");//개똥이 
	 %>
	 <p>이름 : <%=name%></p>
	 
</body>
</html>
                                   결과