SlideShare a Scribd company logo
JEE - JavaServer Pages (JSP)
& Expression Language (EL)
Fahad R. Golra
ECE Paris Ecole d'Ingénieurs - FRANCE
Lecture 4 - JSP & EL
• JSP
• Scripting elements
• Directive elements
• Standard action elements
!
• EL
• Implicit Objects
• Getting Information
2 JEE - JSP & EL
Servlet vs. JSP
3 JEE - JSP & EL
<html>
<body>
<% String name =
request.getParameter(uName); %>
Username: <%= name %>
</body>
</html>
public void doGet(request, response)
{
PrintWriter out = response.getWriter();
String name =
request.getParameter(uName);
out.println( <html><body> );
out.println(”Username: + name);
out.println( </body></html> );
}
Servlets
HTML in Java
JSP
Java in HTML
JSP Architecture
4 JEE - JSP & EL
client Web Server
HTTP Request
HTTP Response
hello.jsp
helloServlet.java
helloServlet.class
read
parse
compile
execute
translationphaserequestprocessing
phase
Implicit Variables in JSP
• request
• This is the HTTPServletRequest object associated with the
request
• response
• This is the HttpServletResponse object associated with the
response to the client
• out
• This is the PrintWriter object used to send output
• session
• This is the HttpSession object associated with request
5 JEE - JSP & EL
Implicit Variables in JSP
• application
• This is the ServletContext object associated with the
application context
!
• config
• This is the ServletConfig object associated with the page
!
• pageContext
• This encapsulates use of server-specific features like higher
performance JspWriters
6 JEE - JSP & EL
Implicit Variables in JSP
• page
• This is a synonym for this. It is used to call the methods
defined by the translated servlet class.
• Exception
• It allows the exception data to be accessed by the designated
JSP
!
• Examples:
• out.print(dataType dt);
• config.getServletName();
• response.setStatus(int statusCode);
• request.getParamter(String name);
7 JEE - JSP & EL
JSP Elements
• There are mainly three types of tag tags (elements) in
JSP, used to put java code in JSP files
• JSP Scripting elements
• JSP Directive elements
• JSP Standard Action elements
8 JEE - JSP & EL
JSP Scripting Elements
• There are four types of JSP Scripting elements
• Declaration tag
• Scripting tag
• Expression tag
• Comment tag
9 JEE - JSP & EL
JSP Declaration tag
• It lets you declare variables and methods in jsp page
• Java code is inside tag
• Variable declaration must end with a semi-colon
!
• Syntax: <%!JavaCode;%>
!
<%! private int i=10;
private int square (int i){
return i*i;
}
%>
10 JEE - JSP & EL
JSP Scripting tag
• It lets you insert java code in the jsp pages
!
• Syntax: <%JavaCode;%>
!
<%
String name = Fabien;
out.println(“Name = “ + name);
%>
11 JEE - JSP & EL
JSP Expression tag
• It is used to insert Java values directly to the output
!
• Syntax: <%=JavaCode%>
!
Current time = <% new java.util.Date()%>
!
12 JEE - JSP & EL
JSP Comment tag
• HTML comments can be seen by the users through
view source
• JSP comments are not visible to the end users
!
• Syntax: <%- - Comment here - -%>
!
<%- - This shows the current date and time- -%>
Current time = <% new java.util.Date()%>
13 JEE - JSP & EL
Scripting Elements Example
<%@ page language="java" contentType="text/html; charset=UTF-8"	
	 pageEncoding="UTF-8"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">	
<html>	
<head>	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
<title>Scripting Element Example</title>	
</head>	
<body>	
	 <%--declaration tag --%>	
	 <%!int i = 10;%>	
!
	 <%--scriptlet tag --%>	
	 <%	
	 	 out.print("i = " + i);	
	 %>	
	 <BR />	
	 <BR />	
	 <%	
	 	 out.print("Loop execution:");	
	 %>	
	 <BR />
14
Scripting Elements Example
<%	
	 	 while (i < 20) {	
	 	 	 out.print("value of i = " + i);	
	 	 	 i++;	
	 %>	
	 <BR />	
	 <%	
	 	 }	
	 %>	
	 <BR />	
	 <%-- expression tag --%>	
	 <%!int a = 5, b = 15;%>	
	 The addition of a + b = 5 + 15 =	
	 <%=a + b%>	
	 <BR /> Current time:	
	 <%=new java.util.Date()%>	
</body>	
</html>
15
Scripting Elements Example
16 JEE - JSP & EL
JSP Directive Elements
• They give special information about the page to JSP
Engine
• They are handled only once at translation phase
!
• Syntax: <%@ directive-name [attribute=“value”
attribute = “value” … ]%>
!
• Types of directives
• page directive
• include directive
• taglib directive
17 JEE - JSP & EL
Page directive
• It is used to specify attributes for the JSP page
• e.g. making session data unavailable to a page
!
!
• Syntax:
<%@ page [attribute=“value” attribute = “value” … ] %>
!
• Example:
<%@ page language=“java” session=“true” … %>
18 JEE - JSP & EL
Page directive - attributes
19
Attribute Description Syntax Example
language The language to be
used in JSP file
language=“java” <%@page
language=“java” %>
import List of packages
need by servlet
import=“package.c
lass,
package.class”
<%@page
import=“java.util.*,
java.io.*” %>
extends superclass of
servlet
extends =
“package.class”
<%@page
extends=“com.ece.Lo
gin” %>
session true binds to
existing session or
creates new. false
means no session
session = “true |
false”
<%@page
session=“true” %>
Page directive - attributes
20
Attribute Description Syntax Example
buffer defines the buffer
size for out.
default is 8kb
buffer=“size(kb) |
none”
<%@page
buffer=“16kb” %>
isThreadS
afe
choice between
multithreading and
single ThreadModel
isThreadSafe=“tru
e | false”
<%@page
isThreadSafe=“true”
%>
autoFlush true means flush
buffer when full,
false means to
throw exception
autoFlush=“true |
false”
<%@page
autoFlush=“true” %>
pageEnco
ding
datatype of page
encoding
pageEncoding=“en
ocding”
<%@page
pageEncoding =
“ISO-8859-1” %>
Page directive - attributes
21
Attribute Description Syntax Example
info string for
getServletInfo
info=“information
message”
<%@page
buffer=“16kb” %>
contentType MIME type of
output
contentType=“MIM
E-Type”
<%@page contentType
=“text/html; charset =
UTF-8” %>
isELignored expression
language available?
isELIgnored=“true
| false”
<%@page isELignored
=“true” %>
isErrorPage Can current page
act as error page ?
isErrorPage=“true
| false”
<%@page isErrorPage =
“false” %>
errorPage define error page
URL for unchecked
runtime exception
errorPage = “URL” <%@page errorPage =
“error.jsp” %>
Include directive
• It is used to insert code (static resource only) of a file
inside jsp file at a specified place in the translation
phase
• Headers, footers, tables and navigation menus that
are common to multiple pages can be placed using it.
!
• Syntax:
<%@ include file=“/folder_name/file_name”%>
!
• Example:
<%@ include file=“footer.html”%>
22 JEE - JSP & EL
Taglib directive
• It make custom actions available in the jsp file, using
the tag libraries
!
• Syntax:
<%tablib uri=“tag Library_path” prefix=“tag_prefix”%>
• uri = Absolute path of a tag library descriptor
• prefix= Prefix to identify custom tags from a specific
library
!
• Example:
<%@ taglib uri=/tlds/ColouredTable.tld” prefix=“ct”@>
23 JEE - JSP & EL
JSP to Servlet translation
24 JEE - JSP & EL
<%@ page import= abc.* %>
<html>
<body>
<% int i = 10; %>
<%! int count = 0; %>
Hello! Welcome
<%! Public void hello()
{
out.println( Hello );
} %>
</body>
</html>
import javax.servlet.HttpServlet.*
import abc.*;
public class Hello_jsp extends HttpServlet
{
int count = 0;
public void hello()
{
out.println( Hello );
}
public void _jspService(req, res)
{
int i = 10;
out.println( <html>r<body> );
out.println( Hello! Welcome );
}
}
JSP Standard Action Elements
• They are used to create, modify or use other objects
!
• Only coded in strict XML syntax
!
• General usage
• inserting a file
• reuse JavaBeans component
• forward to another page
• generate HTML for a Java Plugin, etc.
25 JEE - JSP & EL
Types of standard action types
1. <jsp:param>
2. <jsp:include>
3. <jsp:forward>
4. <jsp:fallback>
5. <jsp:plugin>
6. <jsp:useBean>
7. <jsp:setProperty>
8. <jsp:getProperty>
26 JEE - JSP & EL
Standard action - <jsp:param>
• It provides other tags with additional information as
name value pairs
• Used along with jsp:include, jsp:forward, jsp:plugin
!
• Syntax:
<jsp:param name=“parameter_name”
value=“parameter_value” />
!
<jsp:param name=“parameter_name”
value=“paramter_value> </jsp:param>
27 JEE - JSP & EL
Standard action - <jsp:param>
• Example:
!
<jsp:param name=“font_color” value=“red” />
!
<jsp:param name=“font_color” value=“red”>
<jsp:param>
28 JEE - JSP & EL
Standard action - <jsp:include>
• This allows to include a static or dynamic resource in
the JSP at request time.
• If page is buffered then the buffer is flushed prior to
the inclusion
• Syntax:
<jsp:include page=“file_name” flush=“true|false”/>
!
<jsp:include page=“file_name” flush=“true|false”>
<jsp:param name=“parameter_name”
value=“parameter_value”/>
</jsp:include>
29 JEE - JSP & EL
Example - <jsp:include>
Student.jsp
!
<%@ page language="java" contentType="text/html; charset=UTF-8"	
	 pageEncoding="UTF-8"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">	
<html>	
<head>	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
<title>Student</title>	
</head>	
<body>	
	 <b><i>Student details:</i></b>	
	 <br>	
	 <%	
	 	 out.print(request.getParameter("name1") + " is taking the course of "	
	 	 	 	 + request.getParameter("course1"));	
	 %>	
	 <br>	
	 <%	
	 	 out.print(request.getParameter("name2") + " is taking the course of "	
	 	 	 	 + request.getParameter("course2"));	
	 %>	
</body>	
</html>
30
Example - <jsp:include>
StudentInfo.jsp!
<%@ page language="java" contentType="text/html; charset=UTF-8"	
	 pageEncoding="UTF-8"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/
TR/html4/loose.dtd">	
<html>	
<head>	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
<title>Student Information</title>	
</head>	
<body>	
	 <jsp:include page="Student.jsp">	
	 	 <jsp:param value="Fabien" name="name1" />	
	 	 <jsp:param value="JEE" name="course1" />	
	 	 <jsp:param value="Antoine" name="name2" />	
	 	 <jsp:param value="Java" name="course2" />	
	 </jsp:include>	
</body>	
</html>
31
Directive include vs Action include
32 JEE - JSP & EL
Include Syntax Inclusion
time
Content
type
Parsing
Directive <%@include
file=“file_na
me”%>
Translation
phase
Static Container
Action <jsp:include
page=file_na
me”%>
Request
processing
phase
Static or
dynamic
Not parsed,
included in
the container
Standard action - <jsp:forward>
• This is used to forward the request to another page
!
• Syntax:
<jsp:forward page=“file_name”/>
!
<jsp:forward page=“file_name”>
<jsp:param name=“parameter_name
value=“paramater_value”/>
</jsp:forward>
33 JEE - JSP & EL
Standard action - <jsp:fallback>
• Used in conjunction with <jsp:plugin>
• This element can be used to specify an error string to
be sent to the user in case the plugin fails
!
• Syntax:
<jsp:fallback> text message for user </jsp:fallback>
34 JEE - JSP & EL
Standard action - <jsp:plugin>
• Generates browser-specific code that makes an
Object or Embed tag for the Java plugin
• Can be used for applets and JavaBeans
• Syntax:
<jsp:plugin type=“bean|apple”
code =“className.class”
codebase=“path of className.class in WebRoot”
[name= “name of bean or applet]
[align=“bottom|top|middle|left|right]
[height:”diplayPixels”] ….. >
35 JEE - JSP & EL
Standard action - <jsp:plugin>
[<jsp:params>
<jsp:param name=“parameter_name”
value=“parameter_value”/>
<jsp:param name=“parameter_name”
value=“parameter_value”/>
…….
</jsp:params>]
[<jsp:fallback> text message </jsp:fallback>]
</jsp:plugin>
36 JEE - JSP & EL
Standard action - <jsp:useBean>
• It is used to find and instantiate a JavaBean
• A common way of interaction between web pages
• Scopes:
• page: (default) within a JSP page
• request: within the same request
• session: all JSPs in the same session
• application: within the same context
37 JEE - JSP & EL
Standard action - <jsp:useBean>
• Syntax:
<jsp:useBean id= "bean_id"
scope= "page | request | session | application"
class= “packageName.className"
beanName="packageName.className" >
</jsp:useBean>
38 JEE - JSP & EL
Standard action - <jsp:setProperty>
• It is used to set the value of a bean’s property
!
• Syntax:
!
<jsp:setProperty name="bean_id" property= "*"
| property="propertyName" param="parameterName"
| property="propertyName" value="propertyValue" />
39 JEE - JSP & EL
Standard action - <jsp:getProperty>
• It is used to retrieve the value of a bean’s property,
convert it into a string and insert it into the output.
!
• Syntax:
<jsp:getProperty name=“bean_id”
property=“propertyName”/>
40 JEE - JSP & EL
JSP-JavaBeans Example
package com.ece.jee;	
!
public class BackgroundColor {	
	 int red, blue, green;	
!
public BackgroundColor() {	
	 	 super();	
	 	 this.red = 0;	
	 	 this.blue = 0;	
	 	 this.green = 255;	
	 }	
!
public int getRed() {	
	 	 return red;	
	 }	
!
public void setRed(int red) {	
	 	 this.red = red;	
	 }
41
JSP-JavaBeans Example
public int getBlue() {	
	 	 return blue;	
	 }	
!
public void setBlue(int blue) {	
	 	 this.blue = blue;	
	 }	
!
public int getGreen() {	
	 	 return green;	
	 }	
!
public void setGreen(int green) {	
	 	 this.green = green;	
	 }	
}	
42
JSP-JavaBeans Example
<%@ page language="java" contentType="text/html; charset=UTF-8"	
	 pageEncoding="UTF-8"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">	
<jsp:useBean id="bgc" class="com.ece.jee.BackgroundColor"	
	 scope="session" />	
<html>	
<head>	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
<title>Insert title here</title>	
</head>	
!
<jsp:setProperty name="bgc" property="red" param="red" />	
<jsp:setProperty name="bgc" property="green" param="green" />	
<jsp:setProperty name="bgc" property="blue" param="blue" />
43
JSP-JavaBeans Example
<body	
	 style="background: rgb(<jsp:getProperty name="bgc" property="red"/>, 	
	 <jsp:getProperty name="bgc" property="green"/>, 	
	 <jsp:getProperty name="bgc" property="blue"/>)">	
	 	
	 <h3>Colorful Hello !!!</h3>	
!
	 <form name="colorForm" action="ColorExample.jsp" method="post">	
	 	 Red: <input type="text" name="red"> Green: <input type="text"	
	 	 	 name="green"> Blue: <input type="text" name="blue"> <input	
	 	 	 type="submit">	
	 </form>	
!
</body>	
</html>
44
Initialization parameters
In Deployment Descriptor:
<servlet>	
<servlet-name>InitJSP</servlet-name>	
<jsp-file>/Example.jsp</jsp-file>	
<init-param>	
<param-name>userName</param-name>	
<param-value>Abcd</param-value>	
</init-param>	
</servlet>	
	
<servlet-mapping>	
<servlet-name>InitJSP</servlet-name>	
<url-pattern>/Example.jsp</url-pattern>	
</servlet-mapping>	
!
In JSP:
Our initialization parameter has username value = 	
	 <%= getServletConfig().getInitParameter("userName") %>
45 JEE - JSP & EL
Overriding Init()
<%! 	
public void jspInit(){	
	 String configUser =
getServletConfig().getInitParameter("userName");	
	 getServletContext().setAttribute("contextUser", configUser);	 	
}	
%>	
!
Our initialization parameter has username value = 	
	 <%= config.getInitParameter("userName") %>	
<br/>	
Servlet context value for user = 	
	 <%= application.getAttribute("contextUser") %>
46
JSP Documents
47 JEE - JSP & EL
Expression Language (EL)
• Incorporated in JSP2.0
• Accessing bean using simple syntax
• ${name} for a simple variable
• ${name.foo.bar} for a nested property
!
• Kinds of expressions
• Arithmetic
<jsp:setProperty name="box" property=“perimeter"
value=“${2*box.width+2*box.height}"/>
!
• Logical
<c:if test="${bean1.a < 3}" > ... </c:if>
48 JEE - JSP & EL
Operators in EL
49 JEE - JSP & EL
Operator Description
. Access a bean property or Map entry
[] Access an array or List element
( ) Group a subexpression to change the
evaluation order
+ Addition
- Subtraction or negation of a value
* Multiplication
/ or div Division
% or mod Modulo (remainder)
Operators in EL
50 JEE - JSP & EL
Operator Description
== or eq Test for equality
!= or ne Test for inequality
< or lt Test for less than
> or gt Test for greater than
<= or le Test for less than or equal
>= or gt Test for greater than or equal
&& or and Test for logical AND
|| or or Test for logical OR
! or not Unary Boolean complement
empty Test for null, empty String, array or
Collection.
func(args) A function call
Implicit Objects in EL
51
Implicit object Description
pageScope Scoped variables from page scope
requestScope Scoped variables from request scope
sessionScope Scoped variables from session scope
applicationScope Scoped variables from application scope
param Request parameters as strings
paramValues Request parameters as collections of strings
header HTTP request headers as strings
headerValues HTTP request headers as collections of strings
initParam Context-initialization parameters
cookie Cookie values
pageContext The JSP PageContext object for the current page
Implicit Objects in EL
• Not the same as implicit objects of JSP
• except pageContext
!
• pageContext is used to access other JSP implicit
objects
!
• Syntax:
${pageContext.request.queryString}
52 JEE - JSP & EL
Scope Objects
• These scope objects allow access to variables stored
at different access levels
• requestScope
• sessionScope
• applicationScope
• pageScope
!
• Example
Servlet context value for user = 	
	 <%= application.getAttribute("contextUser") %>	
• Using EL
Servlet context value for user = ${applicationScope.contextUser}
53 JEE - JSP & EL
Handling Attributes
• EL is used to read values, not to set values, JSP
serves as “view” in MVC
!
• In Servlet
request.setAttribute(“contextUser”,cu);
!
• Using EL
${requestScope[“contextUser”].name}
${sessionScope[“contextUser”].name}
${applicationScope[“contextUser”].name}
54 JEE - JSP & EL
Param & ParamValues
• Gives you access to parameter values using
request.getParameter and
request.getParameterValues methods
!
• Example: for a parameter named password
${param.password}
${param[“password”]}
55 JEE - JSP & EL
Getting Header Information
• In JSP
<%= request.getHeader(“host”)%>
!
• With EL
${header.host}
${header[“host”]}
56 JEE - JSP & EL
Init Parameter
• Deployment Descriptor
<context-param>	

<param-name>name</param-name>	

<param-value>Antoine</param-value>
</context-param>
!
• With expression

<%= application.getInitParameter(“name”) %>
!
• With EL
${initParam.name}
57 JEE - JSP & EL
Accessing properties
• If the expression has a variable followed by a dot, then
this variable must be a bean or a map
!
• Example:
${person.name}
58 JEE - JSP & EL
“name”,”Fabien”
name
!
getName()
setName()
java.util.Map a bean
Accessing properties
• If the expression has a variable followed by a bracket,
then this variable must be a bean, a map, a List or an
Array
!
• Example:
${person[name]}
59 JEE - JSP & EL
“name”,”Fabien”
name
!
getName()
setName()
java.util.Map a bean
1. Fabien
2. Antoine
3. Serge
1.Fabien 2.Antoine 3.Serge
an Array
a List
Array
<%!	
String[] nameList = {"Alpha","Bravo","Charlie"}; 	
%>	
!
<% request.setAttribute("name", nameList);%>	
	 	
Name : ${name} 	
<BR />	
Name : ${name[0]} 	
<BR />	
Name : ${name["0"]}
60 JEE - JSP & EL
HashMap
<%!	
Map<String,String> studentMap = new HashMap<String,String>(); 	
%>	
!
<%	
studentMap.put("name","Fabien");	
request.setAttribute("studentMap", studentMap);	
%>	
!
Name : ${studentMap.name} 	
<BR />	
Name : ${studentMap[name]} 	
<BR />	
Name : ${studentMap["name"]}
61 JEE - JSP & EL
Requesting Parameters
• In HTML
<form action=“UserBean.jsp”>

First Name : <input type=“text” name=“firstName”>
Last Name: <input type=“text” name=“lastName”>
<input type=“submit”>	

</form>	

!
• In JSP	

${param.firstName}
${param.lastName}
62 JEE - JSP & EL
63 JEE - JSP & EL

More Related Content

What's hot

Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
BG Java EE Course
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
Talha Ocakçı
 
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
Sasidhar Kothuru
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
sourabh aggarwal
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
Fahad Golra
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
BG Java EE Course
 
Java server pages
Java server pagesJava server pages
Java server pages
Tanmoy Barman
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
Kaml Sah
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Kasun Madusanke
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
yuvalb
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
Yoga Raja
 
Java Servlet
Java ServletJava Servlet
Java Servlet
Yoga Raja
 
Jsp element
Jsp elementJsp element
Jsp element
kamal kotecha
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
deepak kumar
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
Rossen Stoyanchev
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
Tanmoy Barman
 
Jsp
JspJsp
Database connect
Database connectDatabase connect
Database connect
Yoga Raja
 

What's hot (19)

Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Java server pages
Java server pagesJava server pages
Java server pages
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Java Servlet
Java ServletJava Servlet
Java Servlet
 
Jsp element
Jsp elementJsp element
Jsp element
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Jsp
JspJsp
Jsp
 
Database connect
Database connectDatabase connect
Database connect
 

Viewers also liked

Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)
Fahad Golra
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
Fahad Golra
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
Peter R. Egli
 
Tutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital PhotographyTutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital Photography
Fahad Golra
 
Ejb in java. part 1.
Ejb in java. part 1.Ejb in java. part 1.
Ejb in java. part 1.
Asya Dudnik
 
TNAPS 3 Installation
TNAPS 3 InstallationTNAPS 3 Installation
TNAPS 3 Installation
tncor
 
Hibernate
HibernateHibernate
Hibernate
husnara mohammad
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1Asad Khan
 
Introduction to AJAX and DWR
Introduction to AJAX and DWRIntroduction to AJAX and DWR
Introduction to AJAX and DWR
SweNz FixEd
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
Skillwise Group
 
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
Омские ИТ-субботники
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
Nilanjan Roy
 
Apache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate SearchApache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate Search
Vitebsk Miniq
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
kamal kotecha
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
BG Java EE Course
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS IntroductionAlex Su
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013
Matt Raible
 

Viewers also liked (20)

Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Tutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital PhotographyTutorial 4 - Basics of Digital Photography
Tutorial 4 - Basics of Digital Photography
 
Ejb in java. part 1.
Ejb in java. part 1.Ejb in java. part 1.
Ejb in java. part 1.
 
TNAPS 3 Installation
TNAPS 3 InstallationTNAPS 3 Installation
TNAPS 3 Installation
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1
 
Introduction to AJAX and DWR
Introduction to AJAX and DWRIntroduction to AJAX and DWR
Introduction to AJAX and DWR
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
 
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
2012-12-01 03 Битва ORM: Hibernate vs MyBatis. Давайте жить дружно!
 
Jsf Framework
Jsf FrameworkJsf Framework
Jsf Framework
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
 
Apache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate SearchApache Lucene + Hibernate = Hibernate Search
Apache Lucene + Hibernate = Hibernate Search
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS Introduction
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013The Modern Java Web Developer Bootcamp - Devoxx 2013
The Modern Java Web Developer Bootcamp - Devoxx 2013
 

Similar to Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)

Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
JSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODSJSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODS
bharathiv53
 
Jsp1
Jsp1Jsp1
Jsp
JspJsp
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
NishaRohit6
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
 
Jsp 01
Jsp 01Jsp 01
11 page-directive
11 page-directive11 page-directive
11 page-directivesnopteck
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Shah Nawaz Bhurt
 
Chap4 4 2
Chap4 4 2Chap4 4 2
Chap4 4 2
Hemo Chella
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
ManishaPatil932723
 
Jsp
JspJsp
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
ShahDhruv21
 
Ch. 7 beeing a jsp
Ch. 7 beeing a jsp     Ch. 7 beeing a jsp
Ch. 7 beeing a jsp
Manolis Vavalis
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
Subhasis Nayak
 
Jstl
JstlJstl
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
IMC Institute
 

Similar to Lecture 4: JavaServer Pages (JSP) & Expression Language (EL) (20)

Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
 
JSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODSJSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODS
 
Jsp1
Jsp1Jsp1
Jsp1
 
Jsp
JspJsp
Jsp
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
Jsp
JspJsp
Jsp
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
 
Jsp 01
Jsp 01Jsp 01
Jsp 01
 
11 page-directive
11 page-directive11 page-directive
11 page-directive
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Chap4 4 2
Chap4 4 2Chap4 4 2
Chap4 4 2
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
 
J2EE jsp_01
J2EE jsp_01J2EE jsp_01
J2EE jsp_01
 
Jsp
JspJsp
Jsp
 
Jsp Presentation +Mufix "3"
Jsp Presentation +Mufix "3"Jsp Presentation +Mufix "3"
Jsp Presentation +Mufix "3"
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Ch. 7 beeing a jsp
Ch. 7 beeing a jsp     Ch. 7 beeing a jsp
Ch. 7 beeing a jsp
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
 
Jstl
JstlJstl
Jstl
 
Java Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP BasicJava Web Programming [4/9] : JSP Basic
Java Web Programming [4/9] : JSP Basic
 

More from Fahad Golra

Seance 4- Programmation en langage C
Seance 4- Programmation en langage CSeance 4- Programmation en langage C
Seance 4- Programmation en langage C
Fahad Golra
 
Seance 3- Programmation en langage C
Seance 3- Programmation en langage C Seance 3- Programmation en langage C
Seance 3- Programmation en langage C
Fahad Golra
 
Seance 2 - Programmation en langage C
Seance 2 - Programmation en langage CSeance 2 - Programmation en langage C
Seance 2 - Programmation en langage C
Fahad Golra
 
Seance 1 - Programmation en langage C
Seance 1 - Programmation en langage CSeance 1 - Programmation en langage C
Seance 1 - Programmation en langage C
Fahad Golra
 
Tutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital PhotographyTutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital Photography
Fahad Golra
 
Tutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital PhotographyTutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital Photography
Fahad Golra
 
Tutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital PhotographyTutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital Photography
Fahad Golra
 
Deviation Detection in Process Enactment
Deviation Detection in Process EnactmentDeviation Detection in Process Enactment
Deviation Detection in Process EnactmentFahad Golra
 
Meta l metacase tools & possibilities
Meta l metacase tools & possibilitiesMeta l metacase tools & possibilities
Meta l metacase tools & possibilitiesFahad Golra
 

More from Fahad Golra (9)

Seance 4- Programmation en langage C
Seance 4- Programmation en langage CSeance 4- Programmation en langage C
Seance 4- Programmation en langage C
 
Seance 3- Programmation en langage C
Seance 3- Programmation en langage C Seance 3- Programmation en langage C
Seance 3- Programmation en langage C
 
Seance 2 - Programmation en langage C
Seance 2 - Programmation en langage CSeance 2 - Programmation en langage C
Seance 2 - Programmation en langage C
 
Seance 1 - Programmation en langage C
Seance 1 - Programmation en langage CSeance 1 - Programmation en langage C
Seance 1 - Programmation en langage C
 
Tutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital PhotographyTutorial 3 - Basics of Digital Photography
Tutorial 3 - Basics of Digital Photography
 
Tutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital PhotographyTutorial 2 - Basics of Digital Photography
Tutorial 2 - Basics of Digital Photography
 
Tutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital PhotographyTutorial 1 - Basics of Digital Photography
Tutorial 1 - Basics of Digital Photography
 
Deviation Detection in Process Enactment
Deviation Detection in Process EnactmentDeviation Detection in Process Enactment
Deviation Detection in Process Enactment
 
Meta l metacase tools & possibilities
Meta l metacase tools & possibilitiesMeta l metacase tools & possibilities
Meta l metacase tools & possibilities
 

Recently uploaded

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 

Recently uploaded (20)

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 

Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)

  • 1. JEE - JavaServer Pages (JSP) & Expression Language (EL) Fahad R. Golra ECE Paris Ecole d'Ingénieurs - FRANCE
  • 2. Lecture 4 - JSP & EL • JSP • Scripting elements • Directive elements • Standard action elements ! • EL • Implicit Objects • Getting Information 2 JEE - JSP & EL
  • 3. Servlet vs. JSP 3 JEE - JSP & EL <html> <body> <% String name = request.getParameter(uName); %> Username: <%= name %> </body> </html> public void doGet(request, response) { PrintWriter out = response.getWriter(); String name = request.getParameter(uName); out.println( <html><body> ); out.println(”Username: + name); out.println( </body></html> ); } Servlets HTML in Java JSP Java in HTML
  • 4. JSP Architecture 4 JEE - JSP & EL client Web Server HTTP Request HTTP Response hello.jsp helloServlet.java helloServlet.class read parse compile execute translationphaserequestprocessing phase
  • 5. Implicit Variables in JSP • request • This is the HTTPServletRequest object associated with the request • response • This is the HttpServletResponse object associated with the response to the client • out • This is the PrintWriter object used to send output • session • This is the HttpSession object associated with request 5 JEE - JSP & EL
  • 6. Implicit Variables in JSP • application • This is the ServletContext object associated with the application context ! • config • This is the ServletConfig object associated with the page ! • pageContext • This encapsulates use of server-specific features like higher performance JspWriters 6 JEE - JSP & EL
  • 7. Implicit Variables in JSP • page • This is a synonym for this. It is used to call the methods defined by the translated servlet class. • Exception • It allows the exception data to be accessed by the designated JSP ! • Examples: • out.print(dataType dt); • config.getServletName(); • response.setStatus(int statusCode); • request.getParamter(String name); 7 JEE - JSP & EL
  • 8. JSP Elements • There are mainly three types of tag tags (elements) in JSP, used to put java code in JSP files • JSP Scripting elements • JSP Directive elements • JSP Standard Action elements 8 JEE - JSP & EL
  • 9. JSP Scripting Elements • There are four types of JSP Scripting elements • Declaration tag • Scripting tag • Expression tag • Comment tag 9 JEE - JSP & EL
  • 10. JSP Declaration tag • It lets you declare variables and methods in jsp page • Java code is inside tag • Variable declaration must end with a semi-colon ! • Syntax: <%!JavaCode;%> ! <%! private int i=10; private int square (int i){ return i*i; } %> 10 JEE - JSP & EL
  • 11. JSP Scripting tag • It lets you insert java code in the jsp pages ! • Syntax: <%JavaCode;%> ! <% String name = Fabien; out.println(“Name = “ + name); %> 11 JEE - JSP & EL
  • 12. JSP Expression tag • It is used to insert Java values directly to the output ! • Syntax: <%=JavaCode%> ! Current time = <% new java.util.Date()%> ! 12 JEE - JSP & EL
  • 13. JSP Comment tag • HTML comments can be seen by the users through view source • JSP comments are not visible to the end users ! • Syntax: <%- - Comment here - -%> ! <%- - This shows the current date and time- -%> Current time = <% new java.util.Date()%> 13 JEE - JSP & EL
  • 14. Scripting Elements Example <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Scripting Element Example</title> </head> <body> <%--declaration tag --%> <%!int i = 10;%> ! <%--scriptlet tag --%> <% out.print("i = " + i); %> <BR /> <BR /> <% out.print("Loop execution:"); %> <BR /> 14
  • 15. Scripting Elements Example <% while (i < 20) { out.print("value of i = " + i); i++; %> <BR /> <% } %> <BR /> <%-- expression tag --%> <%!int a = 5, b = 15;%> The addition of a + b = 5 + 15 = <%=a + b%> <BR /> Current time: <%=new java.util.Date()%> </body> </html> 15
  • 17. JSP Directive Elements • They give special information about the page to JSP Engine • They are handled only once at translation phase ! • Syntax: <%@ directive-name [attribute=“value” attribute = “value” … ]%> ! • Types of directives • page directive • include directive • taglib directive 17 JEE - JSP & EL
  • 18. Page directive • It is used to specify attributes for the JSP page • e.g. making session data unavailable to a page ! ! • Syntax: <%@ page [attribute=“value” attribute = “value” … ] %> ! • Example: <%@ page language=“java” session=“true” … %> 18 JEE - JSP & EL
  • 19. Page directive - attributes 19 Attribute Description Syntax Example language The language to be used in JSP file language=“java” <%@page language=“java” %> import List of packages need by servlet import=“package.c lass, package.class” <%@page import=“java.util.*, java.io.*” %> extends superclass of servlet extends = “package.class” <%@page extends=“com.ece.Lo gin” %> session true binds to existing session or creates new. false means no session session = “true | false” <%@page session=“true” %>
  • 20. Page directive - attributes 20 Attribute Description Syntax Example buffer defines the buffer size for out. default is 8kb buffer=“size(kb) | none” <%@page buffer=“16kb” %> isThreadS afe choice between multithreading and single ThreadModel isThreadSafe=“tru e | false” <%@page isThreadSafe=“true” %> autoFlush true means flush buffer when full, false means to throw exception autoFlush=“true | false” <%@page autoFlush=“true” %> pageEnco ding datatype of page encoding pageEncoding=“en ocding” <%@page pageEncoding = “ISO-8859-1” %>
  • 21. Page directive - attributes 21 Attribute Description Syntax Example info string for getServletInfo info=“information message” <%@page buffer=“16kb” %> contentType MIME type of output contentType=“MIM E-Type” <%@page contentType =“text/html; charset = UTF-8” %> isELignored expression language available? isELIgnored=“true | false” <%@page isELignored =“true” %> isErrorPage Can current page act as error page ? isErrorPage=“true | false” <%@page isErrorPage = “false” %> errorPage define error page URL for unchecked runtime exception errorPage = “URL” <%@page errorPage = “error.jsp” %>
  • 22. Include directive • It is used to insert code (static resource only) of a file inside jsp file at a specified place in the translation phase • Headers, footers, tables and navigation menus that are common to multiple pages can be placed using it. ! • Syntax: <%@ include file=“/folder_name/file_name”%> ! • Example: <%@ include file=“footer.html”%> 22 JEE - JSP & EL
  • 23. Taglib directive • It make custom actions available in the jsp file, using the tag libraries ! • Syntax: <%tablib uri=“tag Library_path” prefix=“tag_prefix”%> • uri = Absolute path of a tag library descriptor • prefix= Prefix to identify custom tags from a specific library ! • Example: <%@ taglib uri=/tlds/ColouredTable.tld” prefix=“ct”@> 23 JEE - JSP & EL
  • 24. JSP to Servlet translation 24 JEE - JSP & EL <%@ page import= abc.* %> <html> <body> <% int i = 10; %> <%! int count = 0; %> Hello! Welcome <%! Public void hello() { out.println( Hello ); } %> </body> </html> import javax.servlet.HttpServlet.* import abc.*; public class Hello_jsp extends HttpServlet { int count = 0; public void hello() { out.println( Hello ); } public void _jspService(req, res) { int i = 10; out.println( <html>r<body> ); out.println( Hello! Welcome ); } }
  • 25. JSP Standard Action Elements • They are used to create, modify or use other objects ! • Only coded in strict XML syntax ! • General usage • inserting a file • reuse JavaBeans component • forward to another page • generate HTML for a Java Plugin, etc. 25 JEE - JSP & EL
  • 26. Types of standard action types 1. <jsp:param> 2. <jsp:include> 3. <jsp:forward> 4. <jsp:fallback> 5. <jsp:plugin> 6. <jsp:useBean> 7. <jsp:setProperty> 8. <jsp:getProperty> 26 JEE - JSP & EL
  • 27. Standard action - <jsp:param> • It provides other tags with additional information as name value pairs • Used along with jsp:include, jsp:forward, jsp:plugin ! • Syntax: <jsp:param name=“parameter_name” value=“parameter_value” /> ! <jsp:param name=“parameter_name” value=“paramter_value> </jsp:param> 27 JEE - JSP & EL
  • 28. Standard action - <jsp:param> • Example: ! <jsp:param name=“font_color” value=“red” /> ! <jsp:param name=“font_color” value=“red”> <jsp:param> 28 JEE - JSP & EL
  • 29. Standard action - <jsp:include> • This allows to include a static or dynamic resource in the JSP at request time. • If page is buffered then the buffer is flushed prior to the inclusion • Syntax: <jsp:include page=“file_name” flush=“true|false”/> ! <jsp:include page=“file_name” flush=“true|false”> <jsp:param name=“parameter_name” value=“parameter_value”/> </jsp:include> 29 JEE - JSP & EL
  • 30. Example - <jsp:include> Student.jsp ! <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Student</title> </head> <body> <b><i>Student details:</i></b> <br> <% out.print(request.getParameter("name1") + " is taking the course of " + request.getParameter("course1")); %> <br> <% out.print(request.getParameter("name2") + " is taking the course of " + request.getParameter("course2")); %> </body> </html> 30
  • 31. Example - <jsp:include> StudentInfo.jsp! <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Student Information</title> </head> <body> <jsp:include page="Student.jsp"> <jsp:param value="Fabien" name="name1" /> <jsp:param value="JEE" name="course1" /> <jsp:param value="Antoine" name="name2" /> <jsp:param value="Java" name="course2" /> </jsp:include> </body> </html> 31
  • 32. Directive include vs Action include 32 JEE - JSP & EL Include Syntax Inclusion time Content type Parsing Directive <%@include file=“file_na me”%> Translation phase Static Container Action <jsp:include page=file_na me”%> Request processing phase Static or dynamic Not parsed, included in the container
  • 33. Standard action - <jsp:forward> • This is used to forward the request to another page ! • Syntax: <jsp:forward page=“file_name”/> ! <jsp:forward page=“file_name”> <jsp:param name=“parameter_name value=“paramater_value”/> </jsp:forward> 33 JEE - JSP & EL
  • 34. Standard action - <jsp:fallback> • Used in conjunction with <jsp:plugin> • This element can be used to specify an error string to be sent to the user in case the plugin fails ! • Syntax: <jsp:fallback> text message for user </jsp:fallback> 34 JEE - JSP & EL
  • 35. Standard action - <jsp:plugin> • Generates browser-specific code that makes an Object or Embed tag for the Java plugin • Can be used for applets and JavaBeans • Syntax: <jsp:plugin type=“bean|apple” code =“className.class” codebase=“path of className.class in WebRoot” [name= “name of bean or applet] [align=“bottom|top|middle|left|right] [height:”diplayPixels”] ….. > 35 JEE - JSP & EL
  • 36. Standard action - <jsp:plugin> [<jsp:params> <jsp:param name=“parameter_name” value=“parameter_value”/> <jsp:param name=“parameter_name” value=“parameter_value”/> ……. </jsp:params>] [<jsp:fallback> text message </jsp:fallback>] </jsp:plugin> 36 JEE - JSP & EL
  • 37. Standard action - <jsp:useBean> • It is used to find and instantiate a JavaBean • A common way of interaction between web pages • Scopes: • page: (default) within a JSP page • request: within the same request • session: all JSPs in the same session • application: within the same context 37 JEE - JSP & EL
  • 38. Standard action - <jsp:useBean> • Syntax: <jsp:useBean id= "bean_id" scope= "page | request | session | application" class= “packageName.className" beanName="packageName.className" > </jsp:useBean> 38 JEE - JSP & EL
  • 39. Standard action - <jsp:setProperty> • It is used to set the value of a bean’s property ! • Syntax: ! <jsp:setProperty name="bean_id" property= "*" | property="propertyName" param="parameterName" | property="propertyName" value="propertyValue" /> 39 JEE - JSP & EL
  • 40. Standard action - <jsp:getProperty> • It is used to retrieve the value of a bean’s property, convert it into a string and insert it into the output. ! • Syntax: <jsp:getProperty name=“bean_id” property=“propertyName”/> 40 JEE - JSP & EL
  • 41. JSP-JavaBeans Example package com.ece.jee; ! public class BackgroundColor { int red, blue, green; ! public BackgroundColor() { super(); this.red = 0; this.blue = 0; this.green = 255; } ! public int getRed() { return red; } ! public void setRed(int red) { this.red = red; } 41
  • 42. JSP-JavaBeans Example public int getBlue() { return blue; } ! public void setBlue(int blue) { this.blue = blue; } ! public int getGreen() { return green; } ! public void setGreen(int green) { this.green = green; } } 42
  • 43. JSP-JavaBeans Example <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:// www.w3.org/TR/html4/loose.dtd"> <jsp:useBean id="bgc" class="com.ece.jee.BackgroundColor" scope="session" /> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> ! <jsp:setProperty name="bgc" property="red" param="red" /> <jsp:setProperty name="bgc" property="green" param="green" /> <jsp:setProperty name="bgc" property="blue" param="blue" /> 43
  • 44. JSP-JavaBeans Example <body style="background: rgb(<jsp:getProperty name="bgc" property="red"/>, <jsp:getProperty name="bgc" property="green"/>, <jsp:getProperty name="bgc" property="blue"/>)"> <h3>Colorful Hello !!!</h3> ! <form name="colorForm" action="ColorExample.jsp" method="post"> Red: <input type="text" name="red"> Green: <input type="text" name="green"> Blue: <input type="text" name="blue"> <input type="submit"> </form> ! </body> </html> 44
  • 45. Initialization parameters In Deployment Descriptor: <servlet> <servlet-name>InitJSP</servlet-name> <jsp-file>/Example.jsp</jsp-file> <init-param> <param-name>userName</param-name> <param-value>Abcd</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>InitJSP</servlet-name> <url-pattern>/Example.jsp</url-pattern> </servlet-mapping> ! In JSP: Our initialization parameter has username value = <%= getServletConfig().getInitParameter("userName") %> 45 JEE - JSP & EL
  • 46. Overriding Init() <%! public void jspInit(){ String configUser = getServletConfig().getInitParameter("userName"); getServletContext().setAttribute("contextUser", configUser); } %> ! Our initialization parameter has username value = <%= config.getInitParameter("userName") %> <br/> Servlet context value for user = <%= application.getAttribute("contextUser") %> 46
  • 47. JSP Documents 47 JEE - JSP & EL
  • 48. Expression Language (EL) • Incorporated in JSP2.0 • Accessing bean using simple syntax • ${name} for a simple variable • ${name.foo.bar} for a nested property ! • Kinds of expressions • Arithmetic <jsp:setProperty name="box" property=“perimeter" value=“${2*box.width+2*box.height}"/> ! • Logical <c:if test="${bean1.a < 3}" > ... </c:if> 48 JEE - JSP & EL
  • 49. Operators in EL 49 JEE - JSP & EL Operator Description . Access a bean property or Map entry [] Access an array or List element ( ) Group a subexpression to change the evaluation order + Addition - Subtraction or negation of a value * Multiplication / or div Division % or mod Modulo (remainder)
  • 50. Operators in EL 50 JEE - JSP & EL Operator Description == or eq Test for equality != or ne Test for inequality < or lt Test for less than > or gt Test for greater than <= or le Test for less than or equal >= or gt Test for greater than or equal && or and Test for logical AND || or or Test for logical OR ! or not Unary Boolean complement empty Test for null, empty String, array or Collection. func(args) A function call
  • 51. Implicit Objects in EL 51 Implicit object Description pageScope Scoped variables from page scope requestScope Scoped variables from request scope sessionScope Scoped variables from session scope applicationScope Scoped variables from application scope param Request parameters as strings paramValues Request parameters as collections of strings header HTTP request headers as strings headerValues HTTP request headers as collections of strings initParam Context-initialization parameters cookie Cookie values pageContext The JSP PageContext object for the current page
  • 52. Implicit Objects in EL • Not the same as implicit objects of JSP • except pageContext ! • pageContext is used to access other JSP implicit objects ! • Syntax: ${pageContext.request.queryString} 52 JEE - JSP & EL
  • 53. Scope Objects • These scope objects allow access to variables stored at different access levels • requestScope • sessionScope • applicationScope • pageScope ! • Example Servlet context value for user = <%= application.getAttribute("contextUser") %> • Using EL Servlet context value for user = ${applicationScope.contextUser} 53 JEE - JSP & EL
  • 54. Handling Attributes • EL is used to read values, not to set values, JSP serves as “view” in MVC ! • In Servlet request.setAttribute(“contextUser”,cu); ! • Using EL ${requestScope[“contextUser”].name} ${sessionScope[“contextUser”].name} ${applicationScope[“contextUser”].name} 54 JEE - JSP & EL
  • 55. Param & ParamValues • Gives you access to parameter values using request.getParameter and request.getParameterValues methods ! • Example: for a parameter named password ${param.password} ${param[“password”]} 55 JEE - JSP & EL
  • 56. Getting Header Information • In JSP <%= request.getHeader(“host”)%> ! • With EL ${header.host} ${header[“host”]} 56 JEE - JSP & EL
  • 57. Init Parameter • Deployment Descriptor <context-param> <param-name>name</param-name> <param-value>Antoine</param-value> </context-param> ! • With expression
 <%= application.getInitParameter(“name”) %> ! • With EL ${initParam.name} 57 JEE - JSP & EL
  • 58. Accessing properties • If the expression has a variable followed by a dot, then this variable must be a bean or a map ! • Example: ${person.name} 58 JEE - JSP & EL “name”,”Fabien” name ! getName() setName() java.util.Map a bean
  • 59. Accessing properties • If the expression has a variable followed by a bracket, then this variable must be a bean, a map, a List or an Array ! • Example: ${person[name]} 59 JEE - JSP & EL “name”,”Fabien” name ! getName() setName() java.util.Map a bean 1. Fabien 2. Antoine 3. Serge 1.Fabien 2.Antoine 3.Serge an Array a List
  • 60. Array <%! String[] nameList = {"Alpha","Bravo","Charlie"}; %> ! <% request.setAttribute("name", nameList);%> Name : ${name} <BR /> Name : ${name[0]} <BR /> Name : ${name["0"]} 60 JEE - JSP & EL
  • 61. HashMap <%! Map<String,String> studentMap = new HashMap<String,String>(); %> ! <% studentMap.put("name","Fabien"); request.setAttribute("studentMap", studentMap); %> ! Name : ${studentMap.name} <BR /> Name : ${studentMap[name]} <BR /> Name : ${studentMap["name"]} 61 JEE - JSP & EL
  • 62. Requesting Parameters • In HTML <form action=“UserBean.jsp”>
 First Name : <input type=“text” name=“firstName”> Last Name: <input type=“text” name=“lastName”> <input type=“submit”> </form> ! • In JSP ${param.firstName} ${param.lastName} 62 JEE - JSP & EL
  • 63. 63 JEE - JSP & EL