익스프레션 언어 initParam 내장 객체는 웹 애플리케이션의 초기화 파라미터 값을 가져다가 출력할 때 사용합니다.
${initParam.이름} 또는 ${initParam["이름"]
이번 예제는 web.xml 파일과 InitParam.jsp를 만들어야 합니다.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<context-param>
<param-name>MYNAME</param-name>
<param-value>gakari</param-value>
</context-param>
</web-app>
InitParam.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
내 이름은? ${initParam.MYNAME }
</body>
</html>
실행 화면
초기화 파라미터 값이 제대로 가져온 것을 확인할 수 있습니다.
'프로그래밍 > JSP Servlet' 카테고리의 다른 글
JSP/Servlet - 자바의 정적 메소드를 EL 함수로 등록 및 사용 (0) | 2016.01.13 |
---|---|
JSP/Servlet - 익스프레션 언어 javabean의 프로퍼티(Property) 가져오기 (0) | 2016.01.11 |
JSP/Servlet - 익스프레션 언어 Hash Map 객체를 출력하기 (0) | 2016.01.11 |
JSP/Servlet - 익스프레션 언어 List 객체 사용 방법 (0) | 2016.01.10 |
JSP/Servlet - 익스프레션 언어 cookie 내장 객체 사용 방법 (0) | 2016.01.10 |
JSP/Servlet - 익스프레션 언어 (애트리뷰트 및 param, paramValues) (0) | 2016.01.06 |
JSP/Servlet - setAttribute, getAttribute, removeAttribute 메소드에 사용법 (0) | 2016.01.05 |
JSP/Servlet - 웹애플리케이션 초기화 파라미터 (0) | 2016.01.05 |