SlideShare a Scribd company logo
Module 5: EL, JSTL and
    Custom Tags


  Thanisa Kruawaisayawan
   Thanachart Numnonda
   www.imcinstitute.com
Objectives

 Expression Language
 JSTL (JSP Standard Tag Library) 1.1
 Custom Tags




                                        2
Expression Language
   EL expressions are ALWAYS within curly braces,
    and prefixed with the dollar sign
        ${firstThing.secondThing}

   firstThing can be
      EL Implicit Object
      Attribute




                                                     3
EL Implicit Object and Attribute

    EL Implicit Object      Attribute
     param                   in page scope
     paramValues
                              in request scope
     header                  in session scope
     headerValues
                              in application scope
       cookie

       initParam

       pageContext

     pageScope
     requestScope
     sessionScope
     applicationScope

                                                      4
EL Implicit Objects
Implicit Object                    Description
 param              Maps of all the form parameters that were
 paramValues        passed to your JSP
 header             Maps of all the request headers
 headerValues
 cookie             A Map of all the cookies passed to your JSP
 initParam          A Map of the context init parameters
 pageScope          A Map of all the objects that have page,
 requestScope       request, session and application scope
 sessionScope
 applicationScope




                                                                  5
hello.html
<form action="helloName.jsp" method="post">
  Name: <input name="username">
   <input type="submit">
</form>




                                              6
param
<%-- helloName.jsp --%>
Hello <%= request.getParameter("username") %><br>
Hello <% out.print(request.getParameter("username"));%><br>
Hello ${param.username}<br>
Hello ${param['username']}<br>
Hello ${param["username"]}<br>




                                                              7
header
Host is ${header.host} <br>
Cookie is ${header.cookie}




                                8
cookie

JSESSIONID = ${cookie.JSESSIONID.value}




                                          9
initParam
//web.xml
<web-app ...>
   :
   <context-param>
        <param-name> driver </param-name>
        <param-value> com.mysql.jdbc.Driver </param-value>
   </context-param>
   :
</web-app>
---------------------------------------------------------------------------
//InitParamEL.jsp
Driver is ${initParam.driver}




                                                                          10
Person.java

package myBeans;

public class Person {
    private String name;
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
}




                                         11
EL and JavaBeans
<jsp:useBean id="personName" class="myBeans.Person" />
<jsp:setProperty name="personName" property="name" value="Thanisa" />

<%-- <jsp:getProperty name="personName" property="name" /> --%>

${personName.name}




                                                                   12
Disable the EL
   For a single page
    <%@ page isELIgnored="true" %>


   For an entire application
    <jsp-property-group>
       <url-pattern>*.jsp</url-pattern>
       <el-enabled>false</el-enabled>
       <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>




                                                     13
The taglib Directive

   Tag libraries come in two different flavors:
       JSTL (JavaServerPages Standard Tag Library)
       Custom Tag Libraries

   The syntax for the taglib directive is as follows:
<%@ taglib uri=“taglibraryURI” prefix=“tagPrefix” %>




                                                         14
JSTL 1.1
   The “Core” library                The “SQL” library
      Looping and Iteration             Database access
             <c:forEach>                      <sql:query>
             <c:forTokens>                    <sql:update>
                                               <sql:setDataSource>
        Conditional                           <sql:param>
             <c:if>                           <sql:dateParam>
             <c:choose>
             <c:when>
             <c:otherwise>
                                      The “Formatting” library
                                                <fmt:message>
        General-purpose                        :
             <c:out>
             <c:remove>
             <c:catch>               The “XML” library
        URL related                           <x:parse>
             <c:import>                            :
             <c:url>
             <c:redirect>
             <c:param>


                                                                      15
Download and copy JSTL Libraries to
             Tomcat




                                      16
Check JSTL in Project




                        17
Core Tag Library
   Looping and Iteration
   Conditional
   General-purpose
   URL related




                                    18
Looping and Iteration
   <c:forEach>
   <c:forTokens>




                                     19
<c:forEach>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<table border="1" align="center">
    <tr bgcolor="orange">
         <th>Header Names and Values</th>
    </tr>
    <c:forEach var="h" items="${header}">
         <tr>
             <td>${h.value}</td>
         </tr>
    </c:forEach>
</table>




                                                                  20
Result




         21
Conditionals

 <c:if>
 <c:choose>, <c:when> and <c:otherwise>




                                           22
Example




          23
poll.html
:
<body>
   <h3>Do you agree with the opposition
        to boycott the election?</h3>
    <form action = "vote.jsp" method = "post">
       <input type=radio name=answer value="Yes"> Yes<br>
       <input type=radio name=answer value="No"> No<br>
       <input type=radio name=answer value="No Comment"> No Comment<br>
       <br><input type=submit value="VOTE">
    </form>
</body>
:




                                                                   24
<c:if>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"
  prefix="c" %>

<c:if test="${param.answer == 'Yes'}" >
    You vote for Yes
</c:if>
<c:if test="${param.answer == 'No'}" >
    You vote for No
</c:if>
<c:if test="${param.answer == 'No Comment'}" >
    You vote for No Comment
</c:if>




                                                    25
<c:choose>, <c:when> and
               <c:otherwise>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"
  prefix="c" %>

<c:choose>
    <c:when test="${param.field == 'Network'}" >
        You choose Network
    </c:when>
    <c:when test="${param.field == 'Database'}" >
        You choose Database
    </c:when>
    <c:otherwise>
        You choose Programming
    </c:otherwise>
</c:choose>



                                                    26
Scoped Variable Manipulation
 <c:out>
 <c:set>
 <c:remove>
 <c:catch>




                                   27
<c:out>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:forEach begin="3" end="15" step="3" var="index" varStatus="num">
    <c:out value="${index}" />: <c:out value="${num.count}" /><br>
</c:forEach>




                                                                  28
<c:set> and <c:remove>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:set var="status" scope="request" value="On-line" />
Status is ${status} <br>

<c:remove var="status" scope="request" />
Now, status is ${status}




                                                                  29
<c:catch>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

About to do a risky thing <br>
<c:catch var="myException" >
    <% int x = 10/0; %>
</c:catch>
<c:if test="${myException != null}">
    There was an exception: ${myException.message} <br>
</c:if>
If you see this, we survived.




                                                                  30
URL Manipulation
 <c:import>
 <c:redirect>
 <c:url>
 <c:param>




                               31
<c:import>
<%-- Header2.jsp --%>
Information Technology KMITL
-----------------------------------------------------------------
<%-- Test2.jsp --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:import url="http://localhost:8084/SWP_Topic5/Header2.jsp" />
-----------------------------------------------------------------

  The <c:import> action can also
 be used to specify absolute,
 relative and FTP URL resources
 to provide a lot more functionality
 than the standard <jsp:include> action.
 <c:import> can reach OUTSIDE the
   web app

                                                                    32
<c:redirect>
<%-- Header3.jsp --%>
Information Technology KMITL
-----------------------------------------------------------------
<%-- Test3.jsp --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:redirect url="http://localhost:8084/SWP_Topic5/Header3.jsp" />
-----------------------------------------------------------------

   The <c:redirect> action simply
    sends an HTTP redirect to
    a client.




                                                                33
<c:url> and <c:param>
<%-- Header4.jsp --%>
${param.faculty}
-----------------------------------------------------------------
<%-- Test4.jsp --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:url value="http://localhost:8084/SWP_Topic5/Header4.jsp " >
   <c:param name="faculty" value="Information Technology" />
</c:url>
-----------------------------------------------------------------
   The <c:url> action takes care of the encoding and all the URL rewriting.
http://localhost:8084/JSP2/Header.jsp;jsessionid=543ferew432esd23




                                                                               34
SQL Tag Library
 <sql:setDataSource>
 <sql:query>
 <sql:update>
 <sql:param> and <sql:dateParam>
 <sql:transaction>




                                    35
BookStore.jsp
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

<html>
    <head><title>ABC Book Store </title></head>
    <body>
     <center>
      <form action="BookStore.jsp">
      <h1> ABC Book Store </h1>
      <br> Please select a Book and add it to your shopping cart
      </p>

      <sql:setDataSource var="datasource"
             driver="com.mysql.jdbc.Driver"
   url="jdbc:mysql:///test"                                 user="root"
   password="root" />

      <sql:query var="books" dataSource="${datasource}" >
             select * from books
      </sql:query>



                                                                          36
BookStore.jsp (cont.)
                  <table border="1" align="center">
                     <tr bgcolor="orange">
                       <td>ISBN</td><td>Title</td>
                       <td>Author</td><td>Price</td></tr>
                         <c:forEach var="row" items="${books.rows}">
                         <tr>
                              <td>${row.isbn}</td>
                              <td>${row.title} /></td>
                              <td>${row.author} /></td>
                              <td>${row.price} /></td>
                              <td><input type=submit value="add"></td>
                         </tr>
                     </c:forEach>
                </table>
            </form>
        </center>
    </body>
</html>



                                                                         37
Result




         38
Custom Tag Libraries
 The JSP 1.1 specifications introduced the
  ability to define new tags called custom tags
 Can be used in any number of JSP files
 A user can define how the tag, its attributes
  and its body are to be interpreted, and then
  group these tags into collections, called tag
  libraries.

                                                  39
Simple Tag Files
1.   Take an included file (such as “Header.jsp”) and rename it
     with a .tag extension
        <%-- Header.jsp --%>
        <img src="Duke_Cont.png"><br><br>
        Welcome to Java World!!
1.   Put the tag file (such as “Header.tag”) in a directory named
     “tags” inside the “WEB-INF” directory




1.   Put a taglib directive (with a tagdir atttribute) in the JSP
     (TestTag.jsp)
        <%@taglib tagdir="/WEB-INF/tags" prefix="myTags" %>
        <myTags:Header/>
                                                                    40
Result




         41
Components that make up a Tag library
1.   The Tag Library Descriptor (TLD) file
2.   The Tag Handler class
        Classic
        Simple
1.   The JSP file




                                             42
Repeat Tag Implemented as a
                           Classic JSP 1.2 Tag Extension
                 <%@ taglib prefix="my"
                       uri="/mytags" %>
                 <my:repeat num="3">
Usage




                   tag body
                 </my:repeat>



                 int doStartTag() {
                    this.count = this.num;
Implementation




                    return Tag.EVAL_BODY_INCLUDE;
                 }

                 int doAfterBody() {
                    this.count--;
                    return (this.count > 0) ?
                     Tag.EVAL_BODY_AGAIN :
                     Tag.SKIP_BODY;                        43
                 }
Repeat Tag Implemented as a
                     Simple JSP 2.0 Tag Extension
                 <%@ taglib prefix="my"
                       uri="/mytags" %>
Usage




                 <my:repeat num="3">
                   tag body
                 </my:repeat>



                 void doTag() {
Implementation




                   for( int i = 0; i < num; i++ ) {
                      getJspBody().invoke( null );
                   }
                 }



                                                      44
Create a TLD for the tag




                           45
Making a Simple Tag Handler




                              46
JSP File
   Import the tag library
     Specify    location of TLD file and define a tag
        prefix (namespace)
         <%@ taglib uri="myTaglib" prefix="myPrefix" %>
   Use the tags
       <prefix:tagName />
       Prefix comes from taglib directive
       Tag name comes from tag added into TLD file
       Example <myPrefix:myTag />
                                                          47
Write a JSP that uses the tag
<%-- UseCustomTag.jsp --%>
<%@taglib uri="TestMyTag1" prefix="my" %>
<my:test1/>




                                            48
Thank you

   thananum@gmail.com
www.facebook.com/imcinstitute
   www.imcinstitute.com



                                49

More Related Content

What's hot

mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교Woo Yeong Choi
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
Guy Nir
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
zeeshanhanif
 
Réseaux avec NetLogo
Réseaux avec NetLogoRéseaux avec NetLogo
Réseaux avec NetLogo
Alvaro Gil
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
Manav Prasad
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
José Paumard
 
Fondamentaux java
Fondamentaux javaFondamentaux java
Fondamentaux java
Ines Ouaz
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
Surendar Meesala
 
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
MongoDB
 
Automate MariaDB Galera clusters deployments with Ansible
Automate MariaDB Galera clusters deployments with AnsibleAutomate MariaDB Galera clusters deployments with Ansible
Automate MariaDB Galera clusters deployments with Ansible
Federico Razzoli
 
Elasticsearch development case
Elasticsearch development caseElasticsearch development case
Elasticsearch development case
일규 최
 
Les Streams de Java 8
Les Streams de Java 8Les Streams de Java 8
Les Streams de Java 8
Antoine Rey
 
Java 8 - collections et stream
Java 8 - collections et streamJava 8 - collections et stream
Java 8 - collections et stream
Franck SIMON
 
Formation JPA Avancé / Hibernate gratuite par Ippon 2014
Formation JPA Avancé / Hibernate gratuite par Ippon 2014Formation JPA Avancé / Hibernate gratuite par Ippon 2014
Formation JPA Avancé / Hibernate gratuite par Ippon 2014
Ippon
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Lhouceine OUHAMZA
 
Undertow RequestBufferingHandler 소개
Undertow RequestBufferingHandler 소개Undertow RequestBufferingHandler 소개
Undertow RequestBufferingHandler 소개
Ted Won
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
Cours 2 les architectures reparties
Cours 2 les architectures repartiesCours 2 les architectures reparties
Cours 2 les architectures reparties
Mariem ZAOUALI
 
Js scope
Js scopeJs scope

What's hot (20)

mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Réseaux avec NetLogo
Réseaux avec NetLogoRéseaux avec NetLogo
Réseaux avec NetLogo
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
 
Java script
Java scriptJava script
Java script
 
Fondamentaux java
Fondamentaux javaFondamentaux java
Fondamentaux java
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
 
Automate MariaDB Galera clusters deployments with Ansible
Automate MariaDB Galera clusters deployments with AnsibleAutomate MariaDB Galera clusters deployments with Ansible
Automate MariaDB Galera clusters deployments with Ansible
 
Elasticsearch development case
Elasticsearch development caseElasticsearch development case
Elasticsearch development case
 
Les Streams de Java 8
Les Streams de Java 8Les Streams de Java 8
Les Streams de Java 8
 
Java 8 - collections et stream
Java 8 - collections et streamJava 8 - collections et stream
Java 8 - collections et stream
 
Formation JPA Avancé / Hibernate gratuite par Ippon 2014
Formation JPA Avancé / Hibernate gratuite par Ippon 2014Formation JPA Avancé / Hibernate gratuite par Ippon 2014
Formation JPA Avancé / Hibernate gratuite par Ippon 2014
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Undertow RequestBufferingHandler 소개
Undertow RequestBufferingHandler 소개Undertow RequestBufferingHandler 소개
Undertow RequestBufferingHandler 소개
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Cours 2 les architectures reparties
Cours 2 les architectures repartiesCours 2 les architectures reparties
Cours 2 les architectures reparties
 
Js scope
Js scopeJs scope
Js scope
 

Viewers also liked

Java Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationJava Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web Application
IMC Institute
 
Machine Learning using Apache Spark MLlib
Machine Learning using Apache Spark MLlibMachine Learning using Apache Spark MLlib
Machine Learning using Apache Spark MLlib
IMC Institute
 
Mobile User and App Analytics in China
Mobile User and App Analytics in ChinaMobile User and App Analytics in China
Mobile User and App Analytics in China
IMC Institute
 
Thai Software & Software Market Survey 2015
Thai Software & Software Market Survey 2015Thai Software & Software Market Survey 2015
Thai Software & Software Market Survey 2015
IMC Institute
 
บทความสรุปงานสัมมนา IT Trends 2017 ของ IMC Institute
บทความสรุปงานสัมมนา IT Trends 2017 ของ  IMC Instituteบทความสรุปงานสัมมนา IT Trends 2017 ของ  IMC Institute
บทความสรุปงานสัมมนา IT Trends 2017 ของ IMC Institute
IMC Institute
 

Viewers also liked (6)

Java Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web ApplicationJava Web Programming [1/9] : Introduction to Web Application
Java Web Programming [1/9] : Introduction to Web Application
 
Java and the Web
Java and the WebJava and the Web
Java and the Web
 
Machine Learning using Apache Spark MLlib
Machine Learning using Apache Spark MLlibMachine Learning using Apache Spark MLlib
Machine Learning using Apache Spark MLlib
 
Mobile User and App Analytics in China
Mobile User and App Analytics in ChinaMobile User and App Analytics in China
Mobile User and App Analytics in China
 
Thai Software & Software Market Survey 2015
Thai Software & Software Market Survey 2015Thai Software & Software Market Survey 2015
Thai Software & Software Market Survey 2015
 
บทความสรุปงานสัมมนา IT Trends 2017 ของ IMC Institute
บทความสรุปงานสัมมนา IT Trends 2017 ของ  IMC Instituteบทความสรุปงานสัมมนา IT Trends 2017 ของ  IMC Institute
บทความสรุปงานสัมมนา IT Trends 2017 ของ IMC Institute
 

Similar to Java Web Programming [5/9] : EL, JSTL and Custom Tags

Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
Samuel Santos
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
Jennifer Bourey
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
Ankara JUG
 
Jstl Guide
Jstl GuideJstl Guide
Jstl Guide
Yuval Zilberstein
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
Zianed Hou
 
Jsp Notes
Jsp NotesJsp Notes
Jsp Notes
Rajiv Gupta
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
Eric Guo
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
fakeaccount225095
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
Mark
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
Hiro Asari
 
Asynchronous Interfaces
Asynchronous InterfacesAsynchronous Interfaces
Asynchronous Interfaces
maccman
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
Seungkyun Nam
 
DataMapper
DataMapperDataMapper
DataMapper
Yehuda Katz
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
pootsbook
 

Similar to Java Web Programming [5/9] : EL, JSTL and Custom Tags (20)

Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
 
Basic JSTL
Basic JSTLBasic JSTL
Basic JSTL
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
 
Jstl Guide
Jstl GuideJstl Guide
Jstl Guide
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 
Jsp Notes
Jsp NotesJsp Notes
Jsp Notes
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
 
Jsf
JsfJsf
Jsf
 
Asynchronous Interfaces
Asynchronous InterfacesAsynchronous Interfaces
Asynchronous Interfaces
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
 
DataMapper
DataMapperDataMapper
DataMapper
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 

More from IMC Institute

นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14
IMC Institute
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019
IMC Institute
 
บทความ The evolution of AI
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AI
IMC Institute
 
IT Trends eMagazine Vol 4. No.12
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12
IMC Institute
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
IMC Institute
 
IT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to Work
IMC Institute
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
IMC Institute
 
IT Trends eMagazine Vol 4. No.11
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11
IMC Institute
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
IMC Institute
 
บทความ The New Silicon Valley
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon Valley
IMC Institute
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
IMC Institute
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
IMC Institute
 
The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)
IMC Institute
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
IMC Institute
 
IT Trends eMagazine Vol 3. No.9
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9
IMC Institute
 
Thailand software & software market survey 2016
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016
IMC Institute
 
Developing Business Blockchain Applications on Hyperledger
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger
IMC Institute
 
Digital transformation @thanachart.org
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.org
IMC Institute
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
IMC Institute
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
IMC Institute
 

More from IMC Institute (20)

นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019
 
บทความ The evolution of AI
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AI
 
IT Trends eMagazine Vol 4. No.12
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
 
IT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to Work
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
 
IT Trends eMagazine Vol 4. No.11
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
 
บทความ The New Silicon Valley
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon Valley
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
 
The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
 
IT Trends eMagazine Vol 3. No.9
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9
 
Thailand software & software market survey 2016
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016
 
Developing Business Blockchain Applications on Hyperledger
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger
 
Digital transformation @thanachart.org
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.org
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 

Java Web Programming [5/9] : EL, JSTL and Custom Tags

  • 1. Module 5: EL, JSTL and Custom Tags Thanisa Kruawaisayawan Thanachart Numnonda www.imcinstitute.com
  • 2. Objectives  Expression Language  JSTL (JSP Standard Tag Library) 1.1  Custom Tags 2
  • 3. Expression Language  EL expressions are ALWAYS within curly braces, and prefixed with the dollar sign ${firstThing.secondThing}  firstThing can be  EL Implicit Object  Attribute 3
  • 4. EL Implicit Object and Attribute  EL Implicit Object  Attribute  param  in page scope  paramValues  in request scope  header  in session scope  headerValues  in application scope  cookie  initParam  pageContext  pageScope  requestScope  sessionScope  applicationScope 4
  • 5. EL Implicit Objects Implicit Object Description param Maps of all the form parameters that were paramValues passed to your JSP header Maps of all the request headers headerValues cookie A Map of all the cookies passed to your JSP initParam A Map of the context init parameters pageScope A Map of all the objects that have page, requestScope request, session and application scope sessionScope applicationScope 5
  • 6. hello.html <form action="helloName.jsp" method="post"> Name: <input name="username"> <input type="submit"> </form> 6
  • 7. param <%-- helloName.jsp --%> Hello <%= request.getParameter("username") %><br> Hello <% out.print(request.getParameter("username"));%><br> Hello ${param.username}<br> Hello ${param['username']}<br> Hello ${param["username"]}<br> 7
  • 8. header Host is ${header.host} <br> Cookie is ${header.cookie} 8
  • 10. initParam //web.xml <web-app ...> : <context-param> <param-name> driver </param-name> <param-value> com.mysql.jdbc.Driver </param-value> </context-param> : </web-app> --------------------------------------------------------------------------- //InitParamEL.jsp Driver is ${initParam.driver} 10
  • 11. Person.java package myBeans; public class Person { private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } } 11
  • 12. EL and JavaBeans <jsp:useBean id="personName" class="myBeans.Person" /> <jsp:setProperty name="personName" property="name" value="Thanisa" /> <%-- <jsp:getProperty name="personName" property="name" /> --%> ${personName.name} 12
  • 13. Disable the EL  For a single page <%@ page isELIgnored="true" %>  For an entire application <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-enabled>false</el-enabled> <scripting-invalid>true</scripting-invalid> </jsp-property-group> 13
  • 14. The taglib Directive  Tag libraries come in two different flavors:  JSTL (JavaServerPages Standard Tag Library)  Custom Tag Libraries  The syntax for the taglib directive is as follows: <%@ taglib uri=“taglibraryURI” prefix=“tagPrefix” %> 14
  • 15. JSTL 1.1  The “Core” library  The “SQL” library  Looping and Iteration  Database access  <c:forEach>  <sql:query>  <c:forTokens>  <sql:update>  <sql:setDataSource>  Conditional  <sql:param>  <c:if>  <sql:dateParam>  <c:choose>  <c:when>  <c:otherwise>  The “Formatting” library  <fmt:message>  General-purpose :  <c:out>  <c:remove>  <c:catch>  The “XML” library  URL related  <x:parse>  <c:import> :  <c:url>  <c:redirect>  <c:param> 15
  • 16. Download and copy JSTL Libraries to Tomcat 16
  • 17. Check JSTL in Project 17
  • 18. Core Tag Library  Looping and Iteration  Conditional  General-purpose  URL related 18
  • 19. Looping and Iteration  <c:forEach>  <c:forTokens> 19
  • 20. <c:forEach> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <table border="1" align="center"> <tr bgcolor="orange"> <th>Header Names and Values</th> </tr> <c:forEach var="h" items="${header}"> <tr> <td>${h.value}</td> </tr> </c:forEach> </table> 20
  • 21. Result 21
  • 22. Conditionals  <c:if>  <c:choose>, <c:when> and <c:otherwise> 22
  • 23. Example 23
  • 24. poll.html : <body> <h3>Do you agree with the opposition to boycott the election?</h3> <form action = "vote.jsp" method = "post"> <input type=radio name=answer value="Yes"> Yes<br> <input type=radio name=answer value="No"> No<br> <input type=radio name=answer value="No Comment"> No Comment<br> <br><input type=submit value="VOTE"> </form> </body> : 24
  • 25. <c:if> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:if test="${param.answer == 'Yes'}" > You vote for Yes </c:if> <c:if test="${param.answer == 'No'}" > You vote for No </c:if> <c:if test="${param.answer == 'No Comment'}" > You vote for No Comment </c:if> 25
  • 26. <c:choose>, <c:when> and <c:otherwise> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:choose> <c:when test="${param.field == 'Network'}" > You choose Network </c:when> <c:when test="${param.field == 'Database'}" > You choose Database </c:when> <c:otherwise> You choose Programming </c:otherwise> </c:choose> 26
  • 27. Scoped Variable Manipulation  <c:out>  <c:set>  <c:remove>  <c:catch> 27
  • 28. <c:out> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <c:forEach begin="3" end="15" step="3" var="index" varStatus="num"> <c:out value="${index}" />: <c:out value="${num.count}" /><br> </c:forEach> 28
  • 29. <c:set> and <c:remove> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="status" scope="request" value="On-line" /> Status is ${status} <br> <c:remove var="status" scope="request" /> Now, status is ${status} 29
  • 30. <c:catch> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> About to do a risky thing <br> <c:catch var="myException" > <% int x = 10/0; %> </c:catch> <c:if test="${myException != null}"> There was an exception: ${myException.message} <br> </c:if> If you see this, we survived. 30
  • 31. URL Manipulation  <c:import>  <c:redirect>  <c:url>  <c:param> 31
  • 32. <c:import> <%-- Header2.jsp --%> Information Technology KMITL ----------------------------------------------------------------- <%-- Test2.jsp --%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:import url="http://localhost:8084/SWP_Topic5/Header2.jsp" /> -----------------------------------------------------------------  The <c:import> action can also be used to specify absolute, relative and FTP URL resources to provide a lot more functionality than the standard <jsp:include> action.  <c:import> can reach OUTSIDE the web app 32
  • 33. <c:redirect> <%-- Header3.jsp --%> Information Technology KMITL ----------------------------------------------------------------- <%-- Test3.jsp --%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:redirect url="http://localhost:8084/SWP_Topic5/Header3.jsp" /> -----------------------------------------------------------------  The <c:redirect> action simply sends an HTTP redirect to a client. 33
  • 34. <c:url> and <c:param> <%-- Header4.jsp --%> ${param.faculty} ----------------------------------------------------------------- <%-- Test4.jsp --%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:url value="http://localhost:8084/SWP_Topic5/Header4.jsp " > <c:param name="faculty" value="Information Technology" /> </c:url> -----------------------------------------------------------------  The <c:url> action takes care of the encoding and all the URL rewriting. http://localhost:8084/JSP2/Header.jsp;jsessionid=543ferew432esd23 34
  • 35. SQL Tag Library  <sql:setDataSource>  <sql:query>  <sql:update>  <sql:param> and <sql:dateParam>  <sql:transaction> 35
  • 36. BookStore.jsp <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> <html> <head><title>ABC Book Store </title></head> <body> <center> <form action="BookStore.jsp"> <h1> ABC Book Store </h1> <br> Please select a Book and add it to your shopping cart </p> <sql:setDataSource var="datasource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql:///test" user="root" password="root" /> <sql:query var="books" dataSource="${datasource}" > select * from books </sql:query> 36
  • 37. BookStore.jsp (cont.) <table border="1" align="center"> <tr bgcolor="orange"> <td>ISBN</td><td>Title</td> <td>Author</td><td>Price</td></tr> <c:forEach var="row" items="${books.rows}"> <tr> <td>${row.isbn}</td> <td>${row.title} /></td> <td>${row.author} /></td> <td>${row.price} /></td> <td><input type=submit value="add"></td> </tr> </c:forEach> </table> </form> </center> </body> </html> 37
  • 38. Result 38
  • 39. Custom Tag Libraries  The JSP 1.1 specifications introduced the ability to define new tags called custom tags  Can be used in any number of JSP files  A user can define how the tag, its attributes and its body are to be interpreted, and then group these tags into collections, called tag libraries. 39
  • 40. Simple Tag Files 1. Take an included file (such as “Header.jsp”) and rename it with a .tag extension <%-- Header.jsp --%> <img src="Duke_Cont.png"><br><br> Welcome to Java World!! 1. Put the tag file (such as “Header.tag”) in a directory named “tags” inside the “WEB-INF” directory 1. Put a taglib directive (with a tagdir atttribute) in the JSP (TestTag.jsp) <%@taglib tagdir="/WEB-INF/tags" prefix="myTags" %> <myTags:Header/> 40
  • 41. Result 41
  • 42. Components that make up a Tag library 1. The Tag Library Descriptor (TLD) file 2. The Tag Handler class  Classic  Simple 1. The JSP file 42
  • 43. Repeat Tag Implemented as a Classic JSP 1.2 Tag Extension <%@ taglib prefix="my" uri="/mytags" %> <my:repeat num="3"> Usage tag body </my:repeat> int doStartTag() { this.count = this.num; Implementation return Tag.EVAL_BODY_INCLUDE; } int doAfterBody() { this.count--; return (this.count > 0) ? Tag.EVAL_BODY_AGAIN : Tag.SKIP_BODY; 43 }
  • 44. Repeat Tag Implemented as a Simple JSP 2.0 Tag Extension <%@ taglib prefix="my" uri="/mytags" %> Usage <my:repeat num="3"> tag body </my:repeat> void doTag() { Implementation for( int i = 0; i < num; i++ ) { getJspBody().invoke( null ); } } 44
  • 45. Create a TLD for the tag 45
  • 46. Making a Simple Tag Handler 46
  • 47. JSP File  Import the tag library  Specify location of TLD file and define a tag prefix (namespace) <%@ taglib uri="myTaglib" prefix="myPrefix" %>  Use the tags  <prefix:tagName />  Prefix comes from taglib directive  Tag name comes from tag added into TLD file  Example <myPrefix:myTag /> 47
  • 48. Write a JSP that uses the tag <%-- UseCustomTag.jsp --%> <%@taglib uri="TestMyTag1" prefix="my" %> <my:test1/> 48
  • 49. Thank you thananum@gmail.com www.facebook.com/imcinstitute www.imcinstitute.com 49