SlideShare una empresa de Scribd logo
1 de 32
JSTL (JavaServer Pages Standard Tag Library) Борислава Спасова Мартин Чиллев
Съдържание ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSP  потребителски тагове и библиотеки JSP Custom Tags and Tag Libraries
Какво e  потребителски таг ? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Потребителски тагове ,[object Object],[object Object],[object Object],[object Object],[object Object],<myTags:calendar date=&quot;17/12/2006&quot; />
Какво е библиотека с тагове? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Как да използваме библиотека с тагове? ,[object Object],[object Object],[object Object],[object Object],<%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jsp/jstl/core&quot; %> <c:out value=&quot;I am a custom tag&quot; />
JSTL (JavaServer Pages Standard Tag Library) Стандартната библиотека с тагове в  JSP  стандарта
Какво е  JSTL? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Защо JSTL? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSTL Core Tags
JSTL Core тагове ,[object Object],[object Object],<%@ taglib prefix=&quot;c&quot; uri=&quot;http://java.sun.com/jsp/jstl/core&quot;> <%-- Save data in scoped variables --%>  <c:set var=&quot;name1&quot; value=&quot;value1&quot; scope=&quot;page&quot; /> <c:set var=&quot;name2&quot; value=&quot;value2&quot; scope=&quot;request&quot; />  <c:set var=&quot;name3&quot; value=&quot;value3&quot; scope=&quot;session&quot; /> <c:set var=&quot;name4&quot; value=&quot;value4&quot; scope=&quot;application&quot; />
Core тагове ,[object Object],[object Object],[object Object],<c:out value='${pageScope.someBean}' /> <c:out value='${user.login}' />  <c:out value='${user.name}' /> <c:out value='${user.title}' escape Xml ='false' />  <c:remove var=&quot;name&quot; scope=&quot;page&quot; /> <c:catch var=&quot;myException&quot;> Inside the catch… <% int x = 10/0; %> </c:catch>
Core тагове ,[object Object],[object Object],[object Object],<c:if test='${param.p == &quot;someValue&quot;}'>  The property p of param is equal to &quot;someValue&quot; </c:if>  <c:choose>  <c:when test='${param.p == &quot;someValue&quot;}'> Generate this if p equals someValue  </c:when>  <c:otherwise> Otherwise generate this template </c:otherwise> </c:choose>
Core тагове ,[object Object],[object Object],[object Object],<c:forEach var='item' begin='1' end='10'> <c:out value='${item}'/> </c:forEach>  <ul> <c:forEach var='item' items='${itemsList}'> <li><c:out value='${item}'/></li> </c:forEach>  </ul>
Core тагове ,[object Object],[object Object],<c:forEach var='item' items='${map}'>  <c:out value='Key=${item.key} /> <c:out value='Key=${item.value} /> </c:forEach>
Core тагове ,[object Object],[object Object],[object Object],<c:url value=&quot;http://www.somewhere.com/ customers/register&quot; var=&quot;registrationURL&quot;> <c:param name=&quot;name&quot; value=&quot;${param.name}&quot;/> <c:param name=&quot;country&quot;  value=&quot;${param.country}&quot;/> </c:url> <a href='<c:out value=&quot;${registrationURL}“/>'>  Customer Registration>/a> <c:redirect url=&quot;http://www.somewhere.com/register&quot;>
JSTL Formatting and Internationalization Tags
Internationalization тагове ,[object Object],[object Object],[object Object],<%@ taglib uri=&quot;http://java.sun.com/jsp/jstl/fmt&quot; prefix= &quot; fmt &quot; > <fmt:setLocale value=&quot;bg&quot; /> <fmt:requestEncoding value=&quot;UTF-8&quot;/>
Internationalization  тагове ,[object Object],[object Object],<fmt:setBundle basename=&quot;Messages&quot; var= &quot; messagesBundle &quot; /> <fmt:bundle basename=&quot;Messages&quot;> <%-- Контекст повлиян от локализацията --%> <fmt:message key=&quot;EnterUserNameMsg&quot; /> </fmt:bundle>
Internationalization  тагове ,[object Object],[object Object],<fmt:message key=&quot;messageKey&quot; bundle=&quot;resourceBundle&quot;   /> <fmt:message key= &quot; messageKey &quot; bundle= &quot; resourceBundle &quot; > <fmt:param value= &quot; messageValue &quot;  /> </fmt:message>
Internationalization  тагове ,[object Object],[object Object],<fmt:formatNumber value= &quot; ${someNumber} &quot; pattern= &quot; ###,###.## &quot;  /> <fmt:formatDate value= &quot; ${someDate} &quot; pattern= &quot; hh:mm:ss MM/dd/yy &quot;  /> <fmt:formatNumber value= &quot; ${someMoney} &quot; type= &quot; currency|percent|number &quot;  />
Internationalization  тагове ,[object Object],[object Object],<c:catch var=&quot;parsingError&quot; <fmt:parseNumber value=&quot;${numberToParse}&quot; type=&quot;number&quot; var=&quot;parsedNumber&quot;/> </c:catch> <fmt:parseDate value= &quot; 2/5/53 &quot; pattern= &quot; dd/MM/yy &quot;  var= &quot; johnBirthdate &quot; />
Internationalization  тагове ,[object Object],<fmt:timeZone value= &quot; US/Eastern &quot; > <fmt:parseDate value= &quot; 2/5/53 &quot; pattern= &quot; dd/MM/yy &quot;  var= &quot; johnBirthday &quot; /> <fmt:formatDate value= &quot; ${johnBirthday} &quot; dateStyle= &quot; short &quot; /> <%-- ще изкара 5/2/53 --%> </fmt:timeZone>
JSTL XML Tags
JSTL XML тагове ,[object Object],[object Object],[object Object],<%@ taglib uri=&quot;http://java.sun.com/jstl/xml&quot; prefix=&quot;x&quot; %> <x:out select=&quot;$catalog/book/title&quot;/> <x:parse var=&quot;catalog&quot; xml=&quot;${catalogXml}&quot; />
JSTL XML тагове ,[object Object],<x:forEach var=&quot;item&quot; select=&quot;$catalog/items&quot;> <tr> <td><x:out select=&quot;author/name/first&quot; /></td> <td><x:out select=&quot;author/name/last&quot; /></td> <td><x:out select=&quot;title&quot; /></td> <td><x:out select=&quot;price&quot; /></td> </tr> </x:forEach>
JSTL SQL Tags
SQL  тагове ,[object Object],<sql:setDataSource var=&quot;example&quot;   driver=“org.hsqldb.jdbcDriver&quot;   url=&quot;jdbc:hsqldb:file:testdb&quot;   user=“sa&quot;   password=“sa&quot; />
SQL  тагове ,[object Object],<sql:query var= &quot; resultSet&quot; dataSource= &quot; ${example}&quot;   sql= &quot; SELECT BAND, TITLE FROM SONG WHERE ID=? &quot; > <param value= &quot; 1 &quot; > … </sql:query>
SQL  тагове ,[object Object],<sql:update var= &quot; resultSet&quot; dataSource= &quot; ${example}&quot;   sql=&quot;INSERT INTO SONG (BAND, TITLE)  VALUES(?, ?)&quot;> <param value= &quot; AC/DC &quot;  /> <param value= &quot; T.N.T &quot;  /> </sql:update>
JSTL ,[object Object]

Más contenido relacionado

Destacado

JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsBG Java EE Course
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
JSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress comingJSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress comingAndy Schwartz
 
Upcoming JDeveloper ADF Business Components REST support
Upcoming JDeveloper ADF Business Components REST supportUpcoming JDeveloper ADF Business Components REST support
Upcoming JDeveloper ADF Business Components REST supportSteven Davelaar
 
Building Highly Reusable Taskflows
Building Highly Reusable TaskflowsBuilding Highly Reusable Taskflows
Building Highly Reusable TaskflowsSteven Davelaar
 
18 Invaluable Lessons About ADF-JSF Interaction
18 Invaluable Lessons About ADF-JSF Interaction18 Invaluable Lessons About ADF-JSF Interaction
18 Invaluable Lessons About ADF-JSF InteractionSteven Davelaar
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsBG Java EE Course
 
Building beacon-enabled apps with Oracle MCS
Building beacon-enabled apps with Oracle MCSBuilding beacon-enabled apps with Oracle MCS
Building beacon-enabled apps with Oracle MCSSteven Davelaar
 
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and WicketComparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and WicketMatt Raible
 
Alphorm.com Formation Java Server Faces
Alphorm.com Formation Java Server FacesAlphorm.com Formation Java Server Faces
Alphorm.com Formation Java Server FacesAlphorm
 

Destacado (18)

JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
CSS
CSSCSS
CSS
 
JSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress comingJSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress coming
 
Upcoming JDeveloper ADF Business Components REST support
Upcoming JDeveloper ADF Business Components REST supportUpcoming JDeveloper ADF Business Components REST support
Upcoming JDeveloper ADF Business Components REST support
 
Building Highly Reusable Taskflows
Building Highly Reusable TaskflowsBuilding Highly Reusable Taskflows
Building Highly Reusable Taskflows
 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
 
Oracle JET overview
Oracle JET overviewOracle JET overview
Oracle JET overview
 
Rich faces
Rich facesRich faces
Rich faces
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
18 Invaluable Lessons About ADF-JSF Interaction
18 Invaluable Lessons About ADF-JSF Interaction18 Invaluable Lessons About ADF-JSF Interaction
18 Invaluable Lessons About ADF-JSF Interaction
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
Building beacon-enabled apps with Oracle MCS
Building beacon-enabled apps with Oracle MCSBuilding beacon-enabled apps with Oracle MCS
Building beacon-enabled apps with Oracle MCS
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and WicketComparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
Comparing JSF, Spring MVC, Stripes, Struts 2, Tapestry and Wicket
 
Java Server Faces
Java Server FacesJava Server Faces
Java Server Faces
 
Alphorm.com Formation Java Server Faces
Alphorm.com Formation Java Server FacesAlphorm.com Formation Java Server Faces
Alphorm.com Formation Java Server Faces
 

Similar a JSTL

Web applications with Catalyst BG
Web applications with Catalyst BGWeb applications with Catalyst BG
Web applications with Catalyst BGsvilen.ivanov
 
SEO и архитектура на сайт
SEO и архитектура на сайтSEO и архитектура на сайт
SEO и архитектура на сайтВасил Тошков
 
BARS - Regular Expressions - Svetlin Nakov, George Penkov
BARS - Regular Expressions - Svetlin Nakov, George PenkovBARS - Regular Expressions - Svetlin Nakov, George Penkov
BARS - Regular Expressions - Svetlin Nakov, George PenkovSvetlin Nakov
 
Xhtml
XhtmlXhtml
Xhtmlsa6o
 
Html presentation
Html presentationHtml presentation
Html presentationfleexy
 
Xml language
Xml languageXml language
Xml languageTU-Sofia
 
изработка на сайт
изработка на сайтизработка на сайт
изработка на сайтplvasileva90
 
Izrabotka na site
Izrabotka na siteIzrabotka na site
Izrabotka na siteyordanita
 
Училищен курс по програмиране на C# (2013/2014), занятие №13
Училищен курс по програмиране на C# (2013/2014), занятие №13Училищен курс по програмиране на C# (2013/2014), занятие №13
Училищен курс по програмиране на C# (2013/2014), занятие №13DAVID Academy
 

Similar a JSTL (20)

JavaScipt and AJAX Programming
JavaScipt and AJAX ProgrammingJavaScipt and AJAX Programming
JavaScipt and AJAX Programming
 
Web Programming with JavaScript and Ajax
Web Programming with JavaScript and AjaxWeb Programming with JavaScript and Ajax
Web Programming with JavaScript and Ajax
 
Web applications with Catalyst BG
Web applications with Catalyst BGWeb applications with Catalyst BG
Web applications with Catalyst BG
 
Новостите в HTML 5
Новостите в HTML 5Новостите в HTML 5
Новостите в HTML 5
 
SEO и архитектура на сайт
SEO и архитектура на сайтSEO и архитектура на сайт
SEO и архитектура на сайт
 
Xhtml
XhtmlXhtml
Xhtml
 
XML and Web Programming
XML and Web ProgrammingXML and Web Programming
XML and Web Programming
 
BARS - Regular Expressions - Svetlin Nakov, George Penkov
BARS - Regular Expressions - Svetlin Nakov, George PenkovBARS - Regular Expressions - Svetlin Nakov, George Penkov
BARS - Regular Expressions - Svetlin Nakov, George Penkov
 
Html & css improved
Html & css   improvedHtml & css   improved
Html & css improved
 
Xhtml
XhtmlXhtml
Xhtml
 
DHTML
DHTMLDHTML
DHTML
 
DHTML
DHTMLDHTML
DHTML
 
Wordcamp2011
Wordcamp2011Wordcamp2011
Wordcamp2011
 
Html presentation
Html presentationHtml presentation
Html presentation
 
Xml language
Xml languageXml language
Xml language
 
Стар проект на Благо?!
Стар проект на Благо?!Стар проект на Благо?!
Стар проект на Благо?!
 
изработка на сайт
изработка на сайтизработка на сайт
изработка на сайт
 
Izrabotka na site
Izrabotka na siteIzrabotka na site
Izrabotka na site
 
изработка на сайт-seagarden.free.bg
изработка на сайт-seagarden.free.bgизработка на сайт-seagarden.free.bg
изработка на сайт-seagarden.free.bg
 
Училищен курс по програмиране на C# (2013/2014), занятие №13
Училищен курс по програмиране на C# (2013/2014), занятие №13Училищен курс по програмиране на C# (2013/2014), занятие №13
Училищен курс по програмиране на C# (2013/2014), занятие №13
 

Más de BG Java EE Course (19)

HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
WWW and HTTP
WWW and HTTPWWW and HTTP
WWW and HTTP
 
Creating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSSCreating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSS
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Introduction to-RDBMS-systems
Introduction to-RDBMS-systemsIntroduction to-RDBMS-systems
Introduction to-RDBMS-systems
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Basic input-output-v.1.1
Basic input-output-v.1.1Basic input-output-v.1.1
Basic input-output-v.1.1
 
Strings v.1.1
Strings v.1.1Strings v.1.1
Strings v.1.1
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
 
Methods intro-1.0
Methods intro-1.0Methods intro-1.0
Methods intro-1.0
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 
Java platform
Java platformJava platform
Java platform
 

JSTL

Notas del editor

  1. ## * * 07/16/96
  2. ## * * 07/16/96
  3. ## * * 07/16/96
  4. ## * * 07/16/96
  5. ## * * 07/16/96
  6. ## * * 07/16/96
  7. ## * * 07/16/96
  8. ## * * 07/16/96 java.net.URLEncoder – кодиране на URL java.net.URLDecoder – декодиране на URL sendRedirect() - javax.servlet.http.HttpServletResponse – въща заявка към клиента за redirect RequestDispatcher dispatcher = aRequest.getRequestDispatcher(aDestination.toString()); dispatcher.forward(aRequest, aResponse); - прави servlet chain &apos;Refresh: 10; url=http://www.mysite.com/otherpage.php&apos; – client redirect header
  9. ## * * 07/16/96
  10. ## * * 07/16/96
  11. ## * * 07/16/96