개발하자/JSP&Servlet

getRealPath("/"),getContextPath()

i구야 2015. 2. 23. 20:27

 

<%@ 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>
<%
String aPath1=application.getContextPath();
out.println(aPath1+"<br>"); //프로젝트명만 출력

String aPath2=application.getRealPath("/");
out.println(aPath2); //프로젝트까지의 총 경로 출력
%>

</body>
</html>