본문 바로가기
IT관련/JSP

[JSP] 이미지 업로드하기 위해 웹서버 폴더 경로에 접근하는 방법 2가지

by 확고 2022. 2. 9.
728x90
반응형
방법 내용 부가설명
1 String configFolder =
config.getServletContext().getRealPath("접근할 폴더명");
* getRealPath : 폴더에 접근하기 위한 메서드로 생략하면 웹서버 폴더 기본 위치까지만 접근

* 기본 위치 : C:\워크스페이스명\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\프로젝트명
                               
* .getRealPath("eaxm")을 쓰면 eaxm폴더까지 접근.
C:\워크스페이스명\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\프로젝트명/eaxm
2 String saveFolder = "접근할 폴더명";
String requestFolder =
request.getContextPath() + "/" + saveFolder;
※ 둘 다 접근 경로는 같지만 이미지를 올릴 땐
1번째 메서드를 사용하고 웹 서버 폴더에 올려둔
이미지를 가지고 올 땐 2번째 접근 방법을 사용함

 

728x90
반응형

댓글