장점:
Fast development : JSTL은 JSP를 단순화하는 많은 태그를 제공한다.
Code Reusability : 다양한 페이지에서 JSTL 태그를 사용할 수 있다.
scriptlet tag를 사용할 필요가 없다.
-JSTL TAG
1. Core tag : 변수 지원, URL 관리, flow control 등을 제공한다.
URL = "http://java.sun.com/jsp/jstl/core" prefix="c"
< % @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" % >
- c:out
<%= %> 태그 작동 방식과 유사한 표현식의 결과를 나타낸다. 변수의 출력
![스크린샷 2020-01-10 오전 10.28.52.png] (https://images.velog.io/post- images/sia2650/91d3a510-3348-11ea-aa7c-1b3d0b005d91/-2020-01-10-10.28.52.png)
- c:import
상대 또는 절대 URL을 검색하여 내용을 'var'문자열, 'varReader의 Reader 또는 페이지에 표시한다. 페이지 첨부

- c:set
JSP에서 사용될 변수를 설정한다. 변수의 선언
- c:remove
설정한 변수를 제거한다. 변수의 제거!
[스크린샷 2020-01-10 오전 11.29.11.png](https://images.velog.io/post- images/sia2650/ff389540-3350-11ea-99e9-99fed9897c3d/-2020-01-10-11.29.11.png)
- c:catch
exception 처리에 사용된다. 예외 처리

- c:if
조건에 따라 내부 코드를 수행한다. 조건문 (else는 없다)

- c:choose, c:when, c:otherwise
다중 조건을 처리할 때 사용한다. Switch문과 비슷

- c:foreach
컬렉션이나 Map의 각 항목을 처리할 때 사용된다. 반복문

- c:forTokens
구분자로 분리된 각각의 토큰을 처리할 때 사용된다. 구분자로 분할하여 반복문

- c:param
파라미터 추가

- c:redirect
지정한 경로로 리다이렉트 한다. URL 이동

- c:url
URL을 재작성한다. URL 생성

Function tag : 문자열 조작 및 문자열 길이를 지원한다.
URL = "http://java.sun.com/jsp/jstl/functions" prefix="fn"
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn
- fn:endsWith()
str1이 str2로 끝나는 경우 true, 그렇지 않을 경우 false를 반환
boolean endsWith(java.lang.String, java.lang.String)

- fn:startsWith()
str1이 str2로 시작하는 경우 true, 그렇지 않을 경우 false를 반환
boolean fn:startsWith(String input, String prefix)

- fn:escapeXml()
XML의 객체 참조에 해당하는 특수문자를 처리함
java.lang.String escapeXml(java.lang.String)

- fn:indexOf()
str1에서 str2가 위치한 index를 구함
int indexOf(java.lang.String, java.lang.String)

- fn:trim()
str 좌우의 공백 문자 제거
java.lang.String trim(java.lang.String)

- fn:split()
str2로 명시한 글자를 기준으로 str1을 분리해서 배열로 반환
java.lang.String[] split(java.lang.String, java.lang.String)

- fn:toLowerCase()
str을 대문자로 변환
String fn:toLowerCase(String input)

- fn:toUpperCase()
str을 소문자로 변환
String fn:toUpperCase(String input)

- fn:substring()
str.substring(idx1, idx2)의 결과를 반환, idx2가 -1일 경우 str.substring(idx1)과 동일
String fn:substring(String inputstring, int start, int end)

- fn:substringAfter()
str1에서 str1에 포함되어 있는 str2 이후의 문자열을 구함
String fn:substringAfter(String input, String afterstring)

- fn:substringBefore()
str1에서 str1에 포함되어 있는 str2 이전의 문자열을 구함
String fn:substringBefore(String input, String beforestring)

- fn:length()
obj가 Conllection인 경우 저장된 항목의 개수를, 문자인 경우 문자열의 길이를 반환
int length(java.lang.Object)

- fn:replace()
str에 있는 src를 dest로 변환
String fn:replace(String input, String search_for, String replace_with)
Formatting tag : 메시지 형식화, 번호 및 날짜 형식화 등을 지원한다.
URL = "http://java.sun.com/jsp/jstl/fmt" prefix="fmt"
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
XML tag : flow control, transformation 등을 제공한다.
URL = "http://java.sun.com/jsp/jstl/xml" prefix="x"
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
x:out
Xpath에 지정한 패턴에 따라 xml 내용을 출력한다.
<x:out attributes/>
x:parse
xml 문서를 읽어서 파싱한다.
<x:parse attributes> body content </x:parse>
x:set
set : XPath에 따라 선택된 내용을 변수에 저장한다.
<x:set attributes/>
x:choose
<c:choose/> 태그와 같은 기능이다.
<x:choose> body content </x:choose>
x:when
<x:when>은 조건이 true일 때 수행한다. <c:when>와 같다.
<x:when attribute> body content </x:when>
x:otherwise
<x:otherwise>은 조건이 false일 때 수행한다. <c:otherwise> 와 같다.
<x:otherwise> body content </x:otherwise>
x:if
조건문에 사용
<x:if attributes> body content </x:if>
x:transform
xml과 xslt 파일을 결합해서 새로운 형식의 문서를 생성한다.
<x:transform attributes> body content </x:transform>
x:param
<x:param/> 태그는 파라미터 사용 시에 사용된다.
<x:param name="name" value="value"></x:param>
SQL tag : JSTL SQL 태그는 SQL 지원을 제공한다.
URL = "http://java.sun.com/jsp/jstl/sql" prefix="sql"
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
- sql:param
SQL tag에 파라미터를 삽입할 수 있는 태그. 문자열을 파라미터로 사용할 수 있다.
<c:set var="StudentId" value="152"/>
<sql:update dataSource="${db}" var="count">
DELETE FROM Students WHERE Id = ?
<sql:param value="${StudentId}" />
</sql:update>
- sql:dateParam
SQL tag에 파라미터를 삽입할 수 있는 태그. 날짜를 파라미터로 사용할 수 있다.
<%
Date DoB = new Date("2000/10/16");
int studentId = 151;
%>
<sql:update dataSource="${db}" var="count">
UPDATE Student SET dob = ? WHERE Id = ?
<sql:dateParam value="<%=DoB%>" type="DATE" />
<sql:param value="<%=studentId%>" />
</sql:update>

- sql:transaction
transaction을 구현할 때 사용한다.
