본문 바로가기

JAVA/JSP & Servlet

익스프레션 언어(expression language) HashMap

AddressInput.jsp

<%@page import="java.util.HashMap"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

 

<%

        HashMap<String, String> map = new HashMap<String, String>();

        map.put("Edgar", "보스턴");

        map.put("Thomas", "오하이오");

        map.put("John", "워싱턴");

        request.setAttribute("address", map);

        RequestDispatcher dispather = request.getRequestDispatcher("AddressView.jsp");

        dispather.forward(request, response);

 

%>

 

 

 

AddressView.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>익스프레션 : Map 객체 항목 출력</title>

</head>

<body>

 

${param.name } 주소는? : ${address[param.name]}<br>

 

</body>

</html>