전체 글
-
include 디렉티브JSP 2023. 3. 21. 15:38
include 디렉티브 : 액션 태그처럼 지정한 페이지를 현재 위치에 포함시키는 기능을 제공한다. 액션태그는 다른 JSP로 실행 흐름을 이동시켜 실행 결과를 현재 위치에 포함하는 반면에, include 디렉티브는 다른 파일의 내용을 현재 위치에 삽입한 후에 JSP 파일을 자바로 변환하고 컴파일한다 - include 디렉티브를 이용하면, java 문법만으로도 다른 JSP 파일과 데이터를 주고받을 수 있다. 마치 sub 파일의 문법을 그대로 가져와서 쓰는 형식이기 때문에, 컨텐츠 타입에도 주의해야한다. 액션 태그는 레이아웃의 한 구성 요소를 모듈화 하기 위해 사용된다. 반면에 include 디렉티브는 다음 두 가지 목적으로 주로 사용된다. - 모든 JSP 페이지에서 사용하는 변수 지정 - 저작권 표시와 같이..
-
<jsp:include> 액션 태그를 이용한 공통 영역 작성JSP 2023. 3. 21. 14:52
액션 태그 : 액션 태그는 포함할 JSP페이지의 실행 결과를 현제 위치에 포함한다. 액션 태그의 기본 사용방법 page: 포함할 JSP의 경로 flush: 지정한 JSP 페이지를 실행하기 전에 출력 버퍼를 플러시 할지 여부 결정. 기본값은 false이다. - 출력 버퍼를 플러시 한다는 말은 액션 태그를 실행하는 시점에서 출력 버퍼에 저장된 [출력내용A]를 플러시 한 뒤에 sub.jsp 페이지로 흐름이 이동한다는 것을 의미한다. 출력 버퍼를 플러시하면 응답 상태 코드와 HTTP 응답 헤더가 웹 브라우저에 함께 전송된다. 따라서, flush 속성을 true로 지정하면, 이후로 새로운 헤더 정보를 추가해도 반영되지 않는다. 예를 들어 flush가 true라면, sub.jsp에서 response.setHeade..
-
에러 처리 ( 익셉션 직접 처리하기 )JSP 2023. 3. 21. 12:50
익셉션 처리 예제) - 다음은 name 파라메터가 주어지지 않아서 오류화면(익셉션)이 뜨는 코드이다. try-catch 로 익셉션을 처리하자 익셉션 처리 try{ 예외 발생 코드 } catch(Exception ex){ } 에러페이지 지정 응답 상태 코드별로 / 익셉션 타입별로 에러 페이지 지정하기 - Servers 폴더의 web.xml 로 이동한다. 응답 상태 코드별로 에러 페이지 지정 404 /error/error404.jsp 익셉션 타입별로 에러 페이지 지정 404 /error/errorNullPointer.jsp - web-app 태그 사이에 위의 코드를 넣으면, 404 코드가 발생했을 때 location 의 URL로 이동한다.
-
JSP 기본 객체, 속성 사용하기JSP 2023. 3. 21. 12:14
웹 어플리케이션은 네 가지 영역으로 구성된다. - PAGE 영역 : 하나의 JSP 페이지를 처리할 때 사용되는 영역 - REQUEST 영역 : 하나의 HTTP 요청을 처리할 때 사용되는 영역 - SESSION 영역 : 하나의 웹 브라우저와 관련된 영역 ( 로그아웃 하거나 브라우저를 닫으면 초기화된다 ) - APPLICATION 영역 : 하나의 웹 어플리케이션과 관련된 영역 ( 서버를 닫아야 초기화된다 ) JSP 기본 객체의 속성 사용하기 : 속성 처리 메서드 setAttribute(String name, Object value ) / 리턴타입 = void / 이름이 name인 속성의 값을 value로 지정 getAttribute(String name) / 리턴타입 = Object / 이름이 name인 속..
-
웹 어플리케이션 배포 ( eclips - tomcat )JSP 2023. 3. 21. 10:35
웹 어플리케이션을 WAS에 배포하는 방법은 두 가지 방법이 있다. - 대상 폴더에 파일을 직접 복사 - war 파일로 묶어서 배포 톰캣에 war 파일 배포 1. 배포하고자 하는 프로젝트를 .war 파일로 만든다. - 배포할 프로젝트를 export - WAR file로 만든다. 2. .WAR 파일은 톰캣의 webapps 폴더에 저장된다. 3. bin 폴더의 Tomcat8.5w 를 실행해서 Window로 톰캣을 실행시킨다 - Servie Status를 Started로 만든다. - 결과로 webapps 폴더에 해당 프로젝트 파일이 생성되고, 정상적으로 배포가 완료된 것이다. ** eclips로 톰캣이 실행중이라면 충돌이 일어날 수 있으므로 주의하자.