Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS320 Web and Internet Programming JSP Standard Tag Library (JSTL) Chengyu Sun California State University, Los Angeles.

Similar presentations


Presentation on theme: "CS320 Web and Internet Programming JSP Standard Tag Library (JSTL) Chengyu Sun California State University, Los Angeles."— Presentation transcript:

1 CS320 Web and Internet Programming JSP Standard Tag Library (JSTL) Chengyu Sun California State University, Los Angeles

2 Simple JSTL Example JSTL Hello

3 taglib Directive URI A unique identifier for the tag library NOT a real URL Prefix A short name for the tag library Could be an arbitrary name

4 JSP Standard Tag Library (JSTL) LibraryURIPrefix Corehttp://java.sun.com/jsp/jstl/corec XML Processinghttp://java.sun.com/jsp/jstl/xmlx I18N Formattinghttp://java.sun.com/jsp/jstl/fmtfmt Database Accesshttp://java.sun.com/jsp/jstl/sqlsql Functionshttp://java.sun.com/jsp/jstl/functionsfn http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html

5 JSTL Core Flow control  Variable support URL  Output Exception handling

6 JSTL Usage Examples ShoppingCart.jsp Login.jsp and Members.jsp

7 Branch Tags The cart is empty. The cart is emtpy.

8 Loop Tags ${i} ${cart.items[i]}  Exercise

9 Set and Remove Scope Variables In Login.jsp In CheckLogin.jsp In Logout.jsp

10 Set Bean Property name attribute must be a bean declared by target attribute can be any object with a setter Example:

11 URL Tags <x:parsedoc=“${something}” var=“booklist” scope=“application” /> Get book

12 Output You want to use if escapeXML=true value is a Java.io.Reader object ${100} ${price}

13 Character Conversion When escapeXML=true << >> && ‘' “"

14 Exception Handling see Error Page and Exception Handing

15 JSTL Functions fn:length() fn:contains() fn:containsIgnoreCase() fn:startWith() fn:endsWith() fn:indexOf() fn:replace() fn:trim() fn:toUpperCase() fn:toLowerCase() fn:substring() fn:substringAfter() fn:substringBefore() fn:split() fn:join() fn:escapeXML()

16 Function Example Exercise


Download ppt "CS320 Web and Internet Programming JSP Standard Tag Library (JSTL) Chengyu Sun California State University, Los Angeles."

Similar presentations


Ads by Google