📃implicit_init.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MVC</title>
</head>
<body>
<h1>EL 내장객체 - Context Init Parameter</h1>
<hr>
<h3>EL 미사용</h3>
<%-- ServletContext.getInitParameter(String name) : [web.xml] 파일의 context-param 엘리먼트로
제공되는 값을 얻어와 반환하는 메소드 --%>
<p>web.xml 파일에서 제공되는 이름 = <%=config.getServletContext().getInitParameter("name") %></p>
<hr>
<h3>EL 사용</h3>
<%-- EL 표현식에서 initParam 내장객체를 이용하여 [web.xml] 파일의 context-param 엘리먼트로
제공되는 값을 얻어와 출력 가능 --%>
<p>web.xml 파일에서 제공되는 이름 = ${initParam.name }</p>
</body>
</html>
📃web.xml
📌context-param : 모든 웹프로그램에게 값을 제공하기 위한 엘리먼트
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>mvc</display-name>
<context-param>
<param-name>name</param-name>
<param-value>홍길동</param-value>
</context-param>
<filter>
<filter-name>encoding filter</filter-name>
<filter-class>xyz.itwill.filter.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>controller</servlet-name>
<servlet-class>xyz.itwill.mvc.ControllerServlet</servlet-class>
<init-param>
<param-name>configFile</param-name>
<param-value>/WEB-INF/model.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>controller</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
</web-app>