1 / 18

JSP 7 장 익스프레션 언어

JSP 7 장 익스프레션 언어. 유 명 훈 ymh627@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술연구실 2012. 8. 2. 목차. 익스프레션 언어란 ? 익스프레션 언어의 기초 문법 익스프레션 언어의 연산자 익스프레션 언어로 자바의 정적 메소드 호출하기. 익스프레션 언어란 ?. 프로그래밍에서 식 ( 式 ) 이라는 뜻 연산자와 피연산자의 조합을 중심으로 코드를 기술한 언어 ${cnt+1} - EL 식 - 애트리뷰트

Download Presentation

JSP 7 장 익스프레션 언어

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JSP7장 익스프레션 언어 유 명 훈 ymh627@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술연구실 2012. 8. 2

  2. 목차 익스프레션 언어란? 익스프레션 언어의 기초 문법 익스프레션 언어의 연산자 익스프레션 언어로 자바의 정적 메소드 호출하기 IST (Information Sciences & Technology) Laboratory

  3. 익스프레션 언어란? • 프로그래밍에서 식(式)이라는 뜻 • 연산자와 피연산자의 조합을 중심으로 코드를 기술한 언어 • ${cnt+1} - EL식 - 애트리뷰트 • <%= cnt+1 %> - 자바프로그래밍 – 변수 • 데이터 처리 결과를 출력하는 JSP 페이지에 주로 사용 • 복잡한 데이터 처리 로직을 구사할 수 없음 • -, *, /, %, <, >, >=, <=, !=, &&, || • 정적메소드 호출, 결과 출력( ${m:sqrt(100)} ) IST (Information Sciences & Technology) Laboratory

  4. 익스프레션언어의기초 문법(1/6) ${식} ${RESULT} ${RESULT + 101} ${m:sqrt(100)} 데이터 이름 하나로만 구성된 EL식 연산자를 포함한 EL식 자바의 정적 메서드를 호출하는 EL식 ${RESULT} • 데이터 이름 하나로만 구성된 EL식 • setAttribute(), getAttribute(), removeAttribute()4세트 – 애트리뷰트4종류 • pageContext, request, session, application IST (Information Sciences & Technology) Laboratory

  5. 익스프레션언어의기초 문법(2/6) page 애트리뷰트 request 애트리뷰트 session 애트리뷰트 application 애트리뷰트 ${sessionScope.CART} ${application. DB_NAME} ${pageScope. SUM} ${requestScope. RESULT} • 특정한 종류의 애트리뷰트를 출력할 때 - pageScope, requestScope, sessionScope, applicationScope로 표시 • 익스프레션 언어의 내장 객체 IST (Information Sciences & Technology) Laboratory

  6. 익스프레션언어의기초 문법(3/6) ${param.NUM} ${param[“COLOR”]} ${paramValues[“ANIMAL”][1]} ${paramalues.ANIMAL[0]} EL식에 해당하는 데이터가 없어도 에러를 발생시키지 않음 • param • 웹 브라우저에 <FORM> 엘리머트를 통해 입력된 데이터 가져올 때 사용하는 내장 객체 IST (Information Sciences & Technology) Laboratory

  7. 익스프레션언어의기초 문법(4/6) ${header.Host} ${header[“User-Agent”]} 자바의 식별자나 명명규칙을 따라야 함 ${headerValues.Accept[0]} ${headerValues[“User-data”][1]} ${cokie.CART} ${cockie[“User_NAME”]} ${cokie.CART.value} ${cockie[“CART”][“value”]} ${cokie.CART[“value”]} ${cockie[“CART”].value} ${cokie.CART.domain} ${cockie.CART.[“path”]} ${cockie[“CART”][“maxAge”]} • header • HTTP 요청된 메시지의 포함된 HTTP 헤더 값을 가져올 때 사용하는 내장 객체 • cookie • 웹 브라우저가 웹 서버로 보낸 쿠키를 가져올 때 사용하는 내장 객체 • 쿠키의 값이 아닌 쿠키 객체를 가져옴 IST (Information Sciences & Technology) Laboratory

  8. 익스프레션언어의기초 문법(5/6) ${initParam.DB_NAME} ${initParam[“DB_NAME”]} • initParam • 웹 애플리케이션의 초기화 파라미터 값을 가져다가 출력할 때 사용하는 내장 객체 IST (Information Sciences & Technology) Laboratory

  9. 익스프레션언어의기초 문법(6/6) ${pageContext.request} ${pageContext[“request”]} ${pageContext.request.requestURI} ${pageContext[“request”][“requestURI}”]} ${pageContext.request[“requestURI”]} ${pageContext[“request”].requestURI}} • pageContext • JSP 페이지의 주변 환경에 대한 정보를 제공하는 객체 • get수식어 제외하고 첫 문자를 소문자로 바꾸어 준 후 사용 • EX]getRequest • 참조값만출력 • javax.servlet.http.HttpServletRequest클래스의 getRequestURI IST (Information Sciences & Technology) Laboratory

  10. 익스프레션언어의연산자(1/5) ${RESULT+101} 산술 연산자, 비교 연산자, 논리 연산자, 조건 연산자 IST (Information Sciences & Technology) Laboratory

  11. 익스프레션언어의연산자(2/5) 엠프티 연산자 IST (Information Sciences & Technology) Laboratory

  12. 익스프레션언어의연산자(3/5) • 연산자의 우선순위를 바꾸는 괄호 연산자 • 대괄호 연산자와 마침표 연산자 • 데이터의 항목을 가리키기 위해 사용(배열항목, java.util.List, java.util.Map, 자바빈(JavaBean) 프로퍼티) IST (Information Sciences & Technology) Laboratory

  13. 익스프레션언어의연산자(4/5) IST (Information Sciences & Technology) Laboratory

  14. 익스프레션언어의연산자(5/5) 자바빈(JavaBean) IST (Information Sciences & Technology) Laboratory

  15. 익스프레션 언어로 자바의 정적 메서드 호출하기(1/3) ${m:sqrt(100)} <taglibxmlns=“http://java.sun.com/xml/ns/javaee”version =“2.1”> <tlib-version>1.0</tlib-version> <short-name>math</short-name> <name>squareroot</name> <function-class>java.lang.Math</function-class> <function-signature>double sqrt(double)</function-signature> </taglib> <web-app … > <tablib-uri>http://hanb.co.kr/barin07/math-functions</taglib-uri> <tablib-location>/WEB-INF/tlds/math-functions.tld</taglib-location> </web-app> • 조금 더 복잡한 처리를 필요로 할 때 호출 • EL 식에서 호출할 정적 메서드를 웹 컨테이너에 함수로 등록 해 놓아야 함 • 자바의 정적 메서드를EL 함수로 등록하는 방법 • .tld파일에 등록해야 함 • web.xml파일에 TLD 파일을 등록 IST (Information Sciences & Technology) Laboratory

  16. 익스프레션 언어로 자바의 정적 메서드 호출하기(2/3) TLD 파일의 URI JSP페이지 안에서 이를 대신해서 사용할 짧은 이름 <%@tagliburi=“http://hanb.co.kr/barin07/math-functions.tld” prefix=“m” %> jsp, jspx, java, javax, sevlet, sun, sunw는 제외 • EL 함수를 호출하는 방법 • taglib지시자 사용 • uri, prefix 애트리뷰트 기술 IST (Information Sciences & Technology) Laboratory

  17. 익스프레션 언어로 자바의 정적 메서드 호출하기(3/3) • 우리가 직접 작성한 정적 메서드를 호출하는 방법 IST (Information Sciences & Technology) Laboratory

  18. 감사합니다유명훈ymh627@kunsan.ac.kr

More Related