Skip to content

Commit 3a9092c

Browse files
authored
Add files via upload
1 parent dc72466 commit 3a9092c

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

JSTL Reference.pdf

61.6 KB
Binary file not shown.

JSTL tutorials.txt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
2+
JSTL (JSP Standard Tag Libraries)
3+
4+
- It is a collection of JSP custom tags developed by java community process, www.jcp.org.
5+
- Full JSTL contains many common and useful JSP custom tags, particulary used for MVC projects,
6+
based on struts looping and logic tags, not part of the jsp 1.2,2.0 & 2.1
7+
- It allows to use JSP custom tags rather using scriplet code that most JSP programmers are not preferred.
8+
- It encapsulates core functionalities common to many jsp applications.
9+
- It supports for common, structural tasks such as iteration, conditionals, tags for manipulating xml docs,
10+
internationalization tags, sql tags.
11+
12+
1) Core Tags => looping, expression evaluation, basic input and output, etc...
13+
2) Formatting Tags => used to parse data such as dates, etc...
14+
3) SQL tags => enables tags for database access
15+
4) XML tags => can be used to access XML elements
16+
5) JSTL functions => standard functions used mostly for string manipulation
17+
18+
19+
CORE TAGS :
20+
21+
<%@ tagib prefic = "c" uri = "http://java.sun.com/jsp.jstl.core" %>
22+
23+
<c:out> => used for displaying things
24+
<c:set> => set the result of an expression
25+
<c:remove> => removes a scope variable
26+
<c:catch> => catch any exceptions that occur in its body
27+
<c:if> => conditional tag
28+
<c:choose> => conditional tag for mutually exclusive conditional operations using <c:when> and <c:otherwise>
29+
<c:when> => sub tag of <c:choose> which evaluates condition to true
30+
<c:otherwise> => sub tag of <c:choose> that follows <c:when> which runs only when previos condition are false
31+
<c:import> => retreives an absolute or relative url
32+
<c:forEach> => used for Iteration
33+
<c:forTokens> => Itearates over tokens
34+
<c:param> => adds a parameter to a containing import tag's url
35+
<c:redirect> => redirects to a new url
36+
<c:url> => creates a url with optional query parameters
37+
38+
39+
FORMATTING TAGS :
40+
41+
<%@ tagib prefic = "fmt" uri = "http://java.sun.com/jsp.jstl.fmt" %>
42+
43+
<fmt:formatNumber> => to render numeric value with specific precision or format
44+
<fmt:parseNumber> => parse string to number
45+
<fmt:formatDate> => formats date/time using given pattern or style
46+
<fmt:parseDate> => parses string representation of date/time
47+
<fmt:bundle> => loads a resource bundle to be used by its tag body
48+
<fmt:setLocale> => stores the given locale in the locale configuration variable
49+
<fmt:setBundle> => loads a resource bundle and stores it in the named scope variable
50+
<fmt:timeZone> => specifies the timezone for any time formatting
51+
<fmt:setTimeZone> => stores the given time zone
52+
<fmt:message> => to display an internationalized message
53+
<fmt:requestEncoding> => sets the request character encoding
54+
55+
56+
SQL TAGS :
57+
58+
<%@ tagib prefic = "sql" uri = "http://java.sun.com/jsp.jstl.sql" %>
59+
60+
<sql:setDataSource> => creates a simple data source suitable only for prototyping
61+
<sql:query> => executes the sql query defined in its body or the sql attribute
62+
<sql:update> => executes the sql update query defined in its body or the sql attribute
63+
<sql:param> => sets a parameter in an sql statement to the specific value
64+
<sql:dateParam> => sets a parameter in an sql statement to the specific java.util.Date value
65+
<sql:transaction> => provides nested database action elements with a shared connection
66+
67+
68+
XML TAGS :
69+
70+
<%@ tagib prefic = "x" uri = "http://java.sun.com/jsp.jstl.xml" %>
71+
72+
<x:out> => like <%= ... %>, but for Xpath expressions
73+
<x:parse> => use to parse xml data specified
74+
<x:set> => sets a variable to the value of a Xpath expression
75+
<x:if> => evaluates a test Xpath expression and if it is true, it processits body. else it's ignored
76+
<x:forEach> => to loop over nodes in an XML document
77+
<x:choose> => simple conditional tag
78+
<x:when> => sub tag of <choose> which evaluates condition to true
79+
<x:otherwise> => sub tag of <choose> that follows <when> which runs only when previos condition are false
80+
<x:transform> => applies an XSL transformation on a XML document
81+
<x:param> => use along with the transaform tag to set a parameter in the XSLT stylesheet
82+
83+
84+
JSTL FUNCTIONS :
85+
86+
<%@ tagib prefic = "fn" uri = "http://java.sun.com/jsp.jstl.functions" %>
87+
88+
fn:contains() => Tests if input string contains specified substring or not
89+
fn:containsIgnoreCase() => Tests if input string contains specified substring or not ignoring cases
90+
fn:endsWith() => Tests if input string endswith the specified suffix
91+
fn:escapeXml() => escapes character that could be interpreted as XML
92+
fn:indexOf() => returns the index within a string of the first occurance
93+
fn:join() => joins all elements of an array into a string
94+
fn:length() => returns the number of items in a collection or characters in a string
95+
fn:replace => returns string resulting from replacing in an input string all occurances with a given string
96+
fn:split() => splits a string into an array of substrings
97+
98+
99+
EL Expression Language :
100+
101+
- mentioned by using ${..}
102+
103+
eg: ${SessionScope.attribute_name}
104+
105+
106+
107+
Examples using JSTL :
108+
109+
1) counting 1-10 : (using scriplet)
110+
111+
<html>
112+
<body>
113+
<% for(int i=1;i<=10;i++) { %>
114+
<%= i %>
115+
<br>
116+
<% } %>
117+
</body>
118+
</html>
119+
120+
2) counting 1-10 : (using JSTL)
121+
122+
<html>
123+
<body>
124+
<c:forEach var="i" begin="1" end="10" step="1">
125+
<c:out value="${i}"/>
126+
<br>
127+
</c:forEach>
128+
</body>
129+
</html>
130+
131+

0 commit comments

Comments
 (0)