본문 바로가기
study/Jsp

[Jsp] 12. application (application.getMajorVersion(), application.getMinorVersion(), application.getServerInfo(), application.getRealPath("/"), application.setAttribute, session.setAttribute, application.getAttribute, session.getAttribute)

by 금이패런츠 2022. 4. 6.
728x90
반응형
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- src/main/webapp/ch06/application1.jsp --%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>application 객체</title>
</head>
<body>
	<h3>
		application 객체는 웹어플리케이션 당 한개의 객체가 제공됩니다. <br>
		현재 웹어플리케이션 jsp1 프로젝트의 모든 jsp는 하나의 appication 객체를 공유합니다.
	</h3>
	<table border="1" style="border-collapse: collapse;">
		<tr>
			<td>jsp버전</td>
			<td><%=application.getMajorVersion() %>.
				<%=application.getMinorVersion() %></td>
		</tr>
		<tr>
			<td>웹컨테이너 정보(was 서버 정보)</td>
			<td><%=application.getServerInfo() %></td>
		</tr>
		<tr>
			<td>웹어플리케이션 경로</td>
			<td><%=application.getRealPath("/") %></td>
		</tr>
	</table>
<%
application.setAttribute("test","application1.jsp 페이지에서 등록한 속성");
session.setAttribute("test", "application1.jsp 페이지에서 session 등록한 속성");
%>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- src/main/webapp/ch06/application2.jsp --%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%= application.getAttribute("test") %><br>
	<%= session.getAttribute("test") %><br>
</body>
</html>

chap05 필수 이해 요소.pdf
0.23MB

728x90
반응형