® IBM Software Group © 2007 IBM Corporation JSP Expression Language 4.1.0.3.

Slides:



Advertisements
Similar presentations
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Advertisements

Java Server Pages Jeffrey Jongko. Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet.
© Yaron Kanza Advanced Java Server Pages Written by Dr. Yaron Kanza, Edited by permission from author by Liron Blecher.
Expression Language Lec Umair Javed©2006 Generating Dynamic Contents Technologies available  Servlets  JSP  JavaBeans  Custom Tags  Expression.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
DT211/3 Internet Application Development
DT228/3 Web Development JSP: Directives and Scripting elements.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development JSP Final Remarks 10 th March 2005 Bogdan L. Vrusias
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
ASHIMA KALRA.  INTRODUCTION TO JSP INTRODUCTION TO JSP  IMPLICIT OBJECTS IMPLICIT OBJECTS  COOKIES COOKIES.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
JavaServer Faces Jeff Schmitt October 5, Introduction to JSF Presents a standard framework for building presentation tiers for web applications.
Introduction to Java Server Pages (JSPs) Robert Thornton.
Chapter 7 Java Server Pages. Objectives Explain how the separation of concerns principle applies to JSP Describe the operation and life-cycle of a JSP.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
Jordan Anastasiade. All rights reserved.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Java Server Pages™ A technology for serving dynamic web content Stanisław Osiński,
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
16-Oct-15 JSP Implicit Objects. 2 JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer.
JSTL: The JavaServer Pages Standard Tag Library Mark A. Kolb Security Broadband, Austin, TX
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
COMP 321 Week 10. Overview Using Beans in JSP Expression Language JSTL Lab 10-1 Introduction Exam Review.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
JSP Expression Language (EL) 25-Nov-15. JSP - E XPRESSION L ANGUAGE (EL) Introduction Expression Language was first introduced in JSTL 1.0 (JSP Standard.
Java Server Pages Introduction. Servlet Drawbacks Web page designer will need to know servlets to design the page. Servlet will have to be compiled for.
Chapter 11 Invoking Java Code with JSP Scripting Elements.
JSP Custom Tags. Prerequisites Servlet API Mapping to JSP implicit objects JavaServer Pages Basic syntax Implementation via servlet API XML.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
1 Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Chapter 3 JSP Overview. The Problem with Servlets processing the request and generating the response are both handled by a single servlet class Java programming.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
14 Copyright © 2004, Oracle. All rights reserved. Enhancing the User Interface.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
Intermediate JSP Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic Java.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Java Server Pages. 2 Servlets The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
JSP in Action. JSP Standard Actions forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params,
Chapter 14 Using JavaBeans Components in JSP Documents.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
® IBM Software Group © 2007 IBM Corporation JSP Tag Files
JSP Elements Chapter 2.
JSP: Actions elements and JSTL
Invoking Java Code from JSP
MSIS 655 Advanced Business Applications Programming
JavaScript an introduction.
JSP Syntax.
CS320 Web and Internet Programming Expression Language (EL)
CS3220 Web and Internet Programming Expression Language (EL)
CS3220 Web and Internet Programming Expression Language (EL)
Introduction to JSP Dept. of B.Voc Software Development and System Administration St. Joseph’s College(Autonomous) Trichy-02 By Dr. J. Ronald Martin Introduction.
Presentation transcript:

® IBM Software Group © 2007 IBM Corporation JSP Expression Language

2 After completing this unit, you should be able to:  Understand and create JSP expressions using JSP expression language  Understand the use of implicit objects in JSP expression language  Disable expression evaluation when required  Create and deploy JSP expression functions After completing this unit, you should be able to:  Understand and create JSP expressions using JSP expression language  Understand the use of implicit objects in JSP expression language  Disable expression evaluation when required  Create and deploy JSP expression functions Unit objectives

3 JSP Expressions  Expressions allow JSP pages to dynamically access and process server-based data  For example, inserts the current date (on the server) into the HTTP output stream  JSP Pages and JSP Documents have equivalent forms with different syntaxes:  Page:  Document: expr  Expressions are often used to provide dynamic content to static HTML tags <INPUT type="text" name="name" value=" ">

4 Drawbacks of JSP Expressions  Expressions are Java  Along with other forms of scripting, they tend to violate separation of responsibilities  Expressions for simple concepts can become complex  Example - there is a User object in session scope. To access the name of that user might require the following: ((User)session.getAttribute(“user”)).getName()  In JSP Documents, expressions cannot appear inside quotes  Legal: ”>  Illegal:... ”>

5 What is JSP Expression Language?  JSP Expression Language (EL) is a simple language based on:  Local variables of the current page  Nested properties and accessors to collections  Relational, logical and arithmetic operators  A set of implicit objects  Extensible functions mapping into static methods in Java classes  EL is invoked via the construct ${...}  EL may be used:  In attribute values for standard and custom actions  Within template text

6 EL Examples  EL expressions can be used in any attribute that can accept a run-time expression...  EL can be used directly in template text Hello, ${user.firstName} ${user.lastName}

7 Implicit Objects  Several implicit objects are available to EL expressions used in JSP pages:  pageContext  pageScope  requestScope  sessionScope  applicationScope  param  paramValues  header  headerValues  cookie  initParam Example: is equivalent to ${sessionScope.name} Error JSP page examples: ${pageContext.errorData.requestURI} ${pageContext.errorData.throwable}

8 Syntax Overview  Variables are accessed by name  Generalized [ ] and. operators  Can be used to access  Maps  Lists  Arrays of objects  JavaBeans properties  Can be nested arbitrarily  Relational comparisons  Arithmetic and Logical operators Example: to access the name property of the user bean in session scope: ${sessionScope.user.name}

9 Basic Syntax Elements  Literals  Boolean, integer, floating point, string and null  Operators  Accessor. []  Arithmetic + - * / %  Relational == != =  Logical && || !  Empty empty  Conditional ? : ${param.cost * 1.085} ${empty sessionScope ? “yes” : “no”}

10 Named Variables  EL contains a variable resolver which will search the page, request, session, and application scopes for values  For example:  A servlet method contains the code: session.setAttribute("user", aUser);  The servlet then forwards to a JSP with the following EL expression: ${user}  The variable resolver resolves the name to the object in: sessionScope.user  If the attribute is not found in any scope, null is returned  The specification is vague as to what happens when like- named attributes are found in more than one scope

11 Functions  EL functions  Can be mapped to static Java methods in any Java class  Can be invoked in an EL expression  Provide the some of the functionality of custom tags, but much more simply... IBM ${stock:lookup("IBM")} lookup com.ibm.Stockfns java.lang.String lookup(java.lang.String)

12 Functions Example - Add Two Numbers public class AddFunction { public static int addMethod(String x, String y){ int a=0; int b=0; a=Integer.parseInt(x); b=Interger.parseInt(y); return a+b; } addMethod AddFunction int addMethod(java.lang.String, java.lang.String) …. The total amount is ${af:addMethod(amt1, amt2)} Java class Tag Library Descriptor JSP

13 EL Support  The JSP compiler in WebSphere Application Server V6.1 and Rational Application Developer V7.0 supports EL  Required for JSP 2.0 compliance  Application Developer V7.0 does NOT provide explicit support  No content assist  No validation  No wizards  No palette items or snippets Java, not EL

14 Checkpoint 1.How can one recognize an EL expression? 2.In what two places may EL be used? 3.Which EL implicit object contains the attributes of the HTTP session? 4.How are the Java functions that underlie EL functions restricted?

15 Checkpoint solutions 1.EL expressions are enclosed between ${ and }. 2.EL may be used in tag attributes and in template text. 3.sessionScope 4.They must be public static.

16 Having completed this unit, you should be able to:  Understand and create JSP expressions using JSP expression language  Understand the use of implicit objects in JSP expression language  Disable expression evaluation when required  Create and deploy JSP expression functions Having completed this unit, you should be able to:  Understand and create JSP expressions using JSP expression language  Understand the use of implicit objects in JSP expression language  Disable expression evaluation when required  Create and deploy JSP expression functions Unit summary