JSP Programming with a Workbook 1 javax servlet
JSP Programming with a Workbook 내장 객체 (1)
내장 객체 실제 타입 기본 객체 설명 javax. servlet. http. Http. Servlet. Request request 클라이언트 요청 정보 저장 javax. servlet. http. Http. Servlet. Response response 응답 정보 저장 javax. servlet. jsp. Jsp. Writer out 결과 출력 javax. servlet. jsp. Page. Context page. Context 페이지 정보 저장 javax. servlet. Servlet. Context application 웹 어플리케이션 정보 저장 javax. servlet. http. Http. Session session HTTP 세션 정보 저장 javax. servlet. Servlet. Config config 페이지 설정 정보 저장 java. lang. Object page 페이지를 구현한 자바 클래스 인스턴스 java. lang. Throwable exception 예외 객체 3 JSP Programming with a Workbook
response 객체 [1/6] u response 객체 n 사용자가 어떤 요청을 했을 경우 이에 대한 응답을 보내기 위해 사 용 형식 예제 n response. 메소드(변수); response. send. Redirect("http: //java. sun. com"); response. set. Status(response. SC_NOT_FOUND); 메소드 종류 (page. 85 테이블 참고) 9 JSP Programming with a Workbook
response 객체 [2/6] u add. Header() 메소드 n 헤더에 값을 추가 시키고 싶을 경우 사용 u contain. Header() 메소드 n 특정한 헤더 이름이 있는지를 확인하는 메소드 u send. Redirect() 메소드 (코드 3 -9 ~ 코드 3 -10 참고) n 웹페이지 대신 지정한 URL로 이동 형식 예제 response. send. Redirect(URL); response. send. Redirect("http: //java. sun. com"); response. send. Redirect("Form. htm"); 10 JSP Programming with a Workbook
response 객체 [3/6] u set. Status() 메소드, send. Error() 메소드 (코드 3 -11 ~ 코드 3 -12 참고) n 응답에 상태 코드를 전송하는 역할 형식 예제 n response. set. Status([response. 필드 | 코드]); response. set. Status(response. SC_FORBIDDEN); response. set. Status(404); response. send. Error([response. 필드 | 코드]); response. send. Error(response. SC_FORBIDDEN); response. send. Error(404); 상태코드와 메시지 (page. 90 테이블 참고) 11 JSP Programming with a Workbook
response 객체 [4/6] u set. Buffer. Size() 메소드 n 버퍼의 크기 설정 형식 response. set. Buffer. Size (크기); 예제 response. set. Buffer. Size (3200); u get. Buffer. Size() 메소드 n 버퍼의 크기 리턴 형식 response. get. Buffer. Size (크기); 예제 response. get. Buffer. Size (3200); 12 JSP Programming with a Workbook
response 객체 [5/6] u set. Content. Type() 메소드 n n HTTP 콘텐츠 형식 지정 기본값 : text/html 형식 예제 response. set. Content. Type (콘텐츠 형식); response. Content. Type("image/GIF); response. Content. Type(image/JPEG) 13 JSP Programming with a Workbook
response 객체 [6/6] u encode. URL() 메소드 , encode. Redirect. URL() 메소드 (코드 3 -13 참고) n 브라우저가 쿠키를 지원하거나 세션을 유지하지 않은 상태에서 파 라미터로 넘겨진 원래 문자열을 그대로 리턴하는 역할 형식 response. encode. URL(세션ID 및 URL); 예제 response. encode. URL("response_5. jsp? str. ID=apple&str. Pwd=apple") 형식 response. encode. Redirec. URL(세션ID 및 URL); 예제 response. encode. Redirect. URL("response_5. jsp? str. ID=apple&str. Pwd=apple") 14 JSP Programming with a Workbook
out 객체 [1/3] u out 객체 n JSP 페이지가 생성하는 내용을 모두 전달 받음 형식 예제 out. 메소드(변수); out. println("str. Value"); out. clear(); 15 JSP Programming with a Workbook
- Slides: 20