헤르메스 LIFE

The method getServletContext() is undefined for the type HttpServletRequest 본문

Exception

The method getServletContext() is undefined for the type HttpServletRequest

헤르메스의날개 2015. 3. 24. 16:54
728x90

간만에 JSP 프로그래밍..


The method getServletContext() is undefined for the type HttpServletRequest
30:             if(item.getSize() > 0) {
31:                 String ext = item.getName().substring(item.getName().lastIndexOf(".")+1);
32:                 //파일 기본경로
33:                 String defaultPath = request.getServletContext().getRealPath("/");
34:                 //파일 기본경로 _ 상세경로
35:                 String path = defaultPath + "upload" + File.separator;
문제는 request.getServletContext()  인 듯 합니다.

친절하게 포스팅을 하신 분이 계시네요..

감사합니다. ( http://javaking75.blog.me/220072102739 )


이분의 말을 빌리자면..


원인은 HttpServletRequest의 getServletContext() 함수는 Servlet 3.0부터 지원되기 때문이다. 아래 표를 보시면 아시겠지만 Tomcat7부터 Servlet 3.0을 지원한다.

[출처] [오류] HttpServletRequest의 getServletContext() 메서드 사용 문제 [jsp/servlet/spring]|작성자 자바킹


참고로 JSP문서와 서블릿 파일에서 getServletContext() 메서드를 그냥 부르면 Tomcat6 과 Tomcat7에서 에러를 보지 않고 정상적으로 사용 가능 합니다. 여기서 호출한 getServletContext()메서드는 GenericServlet 클래스에 정의된 메서드입니다.

입니다.... ^^


'자바킹'님 감사합니다.









728x90