20140924el.zip
collectionResult.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
${ar[0] }<br />
${map["a"]} <br />
<%@ page import="java.util.*" %>
<%
HashMap<String,String> map = (HashMap<String,String>)request.getAttribute("map");
//map에 저장된 모든 키와 값을 출력
Set<String> keys = map.keySet();
for(String key:keys){
out.println(key+ " : "+map.get(key)+ "<br >");
}
%>
</body>
</html>
elresult.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>attribute 출력</title>
</head>
<body>
자바 코드 사용: <%= request.getAttribute("email") %><br />
EL 이용: ${email} <br />
초기화 파라미터 가져오기: ${initParam.name }<br />
초기화 파라미터 가져오기: ${initParam["name"]}<br />
</body>
</html>
mapCreate.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>EL에서의 컬렉션</title>
</head>
<body>
<%@ page import="java.util.*" %>
<%
//문자열을 저장하는 ArrayList 만들어서 문자열을 저장
ArrayList<String> al = new ArrayList<String>();
al.add("기역");
al.add("니은");
al.add("디귿");
//HashMap 만들어서 문자열을 헤시맵에 저장
HashMap<String, String>map = new HashMap<String,String>();
map.put("a","에이요!");
map.put("b","비요!");
map.put("c","씨요!");
map.put("d","디요!");
request.setAttribute("ar", al);
request.setAttribute("map", map);
RequestDispatcher dispatcher = request.getRequestDispatcher("collectionResult.jsp");
dispatcher.forward(request, response);
%>
</body>
</html>
NewFile.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setAttribute("email", "dltkd1214@gmail.com");
RequestDispatcher dispatcher = request.getRequestDispatcher("elresult.jsp");
dispatcher.forward(request, response);
%>
pageContext.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String uri = request.getRequestURI();
String conextPath = request.getContextPath();
out.println("전체 경로 : "+ uri+"<br />");
out.println("프로젝트 경로 : "+ conextPath+ "<br />");
String command = uri.substring(conextPath.length());
out.println("요청 경로 : "+ command+ "<br />");
%>
</body>
</html>