Java Server Page v JSP v Java Life

  • Slides: 28
Download presentation
Java. Server. Page 전혜영

Java. Server. Page 전혜영

목차 v JSP란… v Java Life Cycle v JSP기본 문법 v Action. Tag v

목차 v JSP란… v Java Life Cycle v JSP기본 문법 v Action. Tag v Cookie / Session v MVC Pattern

Java Life Cycle NO class 파일존재? YES JSP -> 서블릿파일 JAVA -> CLASS jsp요청

Java Life Cycle NO class 파일존재? YES JSP -> 서블릿파일 JAVA -> CLASS jsp요청 M에 로딩? NO jsp. Init ( ) YES _jsp. Service ( ) jsp. Destroy ( )

JSP 기본 문법 v Directive v Scripting v v v Declaration Scriptlet Expression v

JSP 기본 문법 v Directive v Scripting v v v Declaration Scriptlet Expression v Action. Tag v 주석 <!-v <% v HTML 주석 JSP 주석 // /* <%@ %> <%! %> member 선언시 <% %> 자유로운 자바코드 <%= %> 출력 <jsp: tagname /> */ --%> %> %>

_jsp. Service() 내장객체 v request Http. Servlet. Request v response Http. Servlet. Response v

_jsp. Service() 내장객체 v request Http. Servlet. Request v response Http. Servlet. Response v out Print. Writer v session Http. Session v application Servlet. Context v config Servlet. Config v page this와 유사한 개념 v page. Context. Page. Context v exception Exception

2. 1 page directive 속성 <%@page import=“java. util. Array. List” %> v v v

2. 1 page directive 속성 <%@page import=“java. util. Array. List” %> v v v import content. Type error. Page is. Error. Page is. Thread. Safe session buffer autoflush extends info page. Encoding

Action. Tag 종류 v <jsp: use. Bean> v <jsp: set. Property> v <jsp: get.

Action. Tag 종류 v <jsp: use. Bean> v <jsp: set. Property> v <jsp: get. Property> v <jsp: include> v <jsp: forward> v <jsp: plugin>

객체 생성<jsp: use. Bean> v <jsp: use. Bean id=‘객체명’ class=‘클래스명’ scope=‘범위’/> v <jsp: use.

객체 생성<jsp: use. Bean> v <jsp: use. Bean id=‘객체명’ class=‘클래스명’ scope=‘범위’/> v <jsp: use. Bean id=‘bean’ class=‘pack. ABean’/> v <% pack. ABean bean = new pack. ABean() %> v scope에 범위를 지정하면 다른 페이지에서 도 빈객체를 공유

v 빈의 공유 v page - Page. Context 객체에 저장 ( 기본값 ) v

v 빈의 공유 v page - Page. Context 객체에 저장 ( 기본값 ) v request - Servlet. Request 객체에 저장 v session - Http. Session 객체에 저장 v application - Servlet. Context 객체에 저장

속성<jsp: get. Property> v <jsp: get. Property name=‘빈객체명’ property=‘속성이름’/> name : <jsp: use. Bean>의

속성<jsp: get. Property> v <jsp: get. Property name=‘빈객체명’ property=‘속성이름’/> name : <jsp: use. Bean>의 id 값과 동일 v property : 빈클래스의 get. XXXX()의 XXXX에 해당되는 이름 ( 첫글자만 소문자 ) v v <jsp: get. Property name=‘bean’ property=‘attribute’/> v <% bean. get. Attirbute(); %>

속성<jsp: set. Property> v <jsp: set. Property name=‘빈객체명’ property=‘속성이름’/> v v name : <jsp:

속성<jsp: set. Property> v <jsp: set. Property name=‘빈객체명’ property=‘속성이름’/> v v name : <jsp: use. Bean>의 id 값과 동일 property : 빈클래스의 set. XXXX()의 XXXX에 해당되는 이름 ( 첫글자만 소문자 ) v <jsp: set. Property name=‘bean’ property=‘attribute’/> v <% String a = request. get. Parameter(“attribute”); bean. set. Attirbute( a ); %> v 만일 폼의 각 요소 이름과 빈의 속성이름이 대소문자까지 모두 일치하다면 *문자 사용이 가능 v <jsp: set. Property name=‘빈즈객체명’ property=‘*’/>

v 비교 1 - <jsp: include> request 시 main. jsp ~~~~~ <jsp: include page=‘sub.

v 비교 1 - <jsp: include> request 시 main. jsp ~~~~~ <jsp: include page=‘sub. jsp’/> ~~~~~ sub. jsp =====

v 비교 2 - <%@ include file=‘url’ %> main. jsp ~~~~~ 서블릿 변환시 _main_jsp.

v 비교 2 - <%@ include file=‘url’ %> main. jsp ~~~~~ 서블릿 변환시 _main_jsp. java ~~~~~ <%@ include fiel=‘sub. jsp’ %> ~~~~~ sub. jsp ===== ~~~~~

페이지 전환 v <jsp: forward page=‘url’ /> v 기존의 request 연결을 유지하면서 서버상의 url로

페이지 전환 v <jsp: forward page=‘url’ /> v 기존의 request 연결을 유지하면서 서버상의 url로 request 정보를 전달 v 서블릿상에서 Request. Dispatcher rd = get. Servlet. Context(). get. Request. Dispatcher(“url”); rd. forward( request, response ); v <참고> response. send. Redirect(“url”); 이는 기존 연결을 끊고, 새로운 url로 재접속을 하 기에 요청정보를 유지하지 못한다

Model 1 Architecture

Model 1 Architecture

Model 2 Architecture

Model 2 Architecture

3 -Tier Web Architecture

3 -Tier Web Architecture

Java 2 Platform, Enterprise Edition

Java 2 Platform, Enterprise Edition

Java Naming and directory Interface

Java Naming and directory Interface