Organization of the platform Your application Java language Java Servlet API JavaServer Pages (JSP) JSTL Your web pages.

Slides:



Advertisements
Similar presentations
9 Copyright © 2005, Oracle. All rights reserved. Modularizing JavaServer Pages Development with Tags.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
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.
Apache Struts Technology
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.
JSTL and Web Development at Universities Shawn Bayern Research programmer, Yale University JSTL reference-implementation lead Author, Web Development with.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
DT211/3 Internet Application Development
JSP 2.0 and JSTL: Principles and Patterns Shawn Bayern Research Programmer, Yale University JSTL reference-implementation lead Author, JSTL in Action Web.
DT228/3 Web Development JSP: Directives and Scripting elements.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
Apache Struts Technology A MVC Framework for Java Web Applications.
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 Java web programming Dr Jim Briggs JWP intro1.
Chapter 10 Servlets and Java Server Pages. A servlet is a Java class designed to be run in the context of a special servlet container An instance of the.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
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.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
JSP Standard Tag Library
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
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.
® IBM Software Group © 2007 IBM Corporation JSP Custom Tags
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Jordan Anastasiade. All rights reserved.
Using JSP 2.0’s New Features Shawn Bayern Research Programmer, Yale University JSTL reference-implementation lead Author, JSTL in Action Web Development.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
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.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
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.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
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.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
JSTL The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
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.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© 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.
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.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
Apache Struts Technology A MVC Framework for Java Web Applications.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
Web browser Web server HTML request Scripted pagedatabase The following components will be used: Apache Jakarta Tomcat servlet engine Derby JavaServer.
JSP: Actions elements and JSTL
JSP (Java Server Page) JSP is server side technology which is used to create dynamic web pages just like Servlet technology. This is mainly used for implementing.
Knowledge Byte In this section, you will learn about:
JSP Standard Tag Library
CS320 Web and Internet Programming Expression Language (EL)
JSP 2.0 and JSTL: Principles and Patterns
CS3220 Web and Internet Programming Expression Language (EL)
CS3220 Web and Internet Programming Expression Language (EL)
Presentation transcript:

Organization of the platform Your application Java language Java Servlet API JavaServer Pages (JSP) JSTL Your web pages

What’s irritating about Custom Tags? The tag-extension protocol is too complicated Tag handler  doStartTag()doEndTag() doCatch()doFinally() doInitBody() doAfterBody() release() Too hard for Gosling, even?

What’s irritating about JSP? Also, tags don’t support certain kinds of code reuse. ”> : out.println(…); for(…) { out.println(…); … } 

What’s bad about JSP? (  ) The general consensus says… Scriplets They complicate abstraction and code reuse. They make it harder for nonprogrammers to maintain pages

JSP 2.0 Sun introduced the solution to these problems in JSP 2.0. It addresses theses issues by introducing Expression language Tag files Simplified Tag API (SimpleTag versus Tag) Improved XML syntax JSTL, although it is not part of JSP specificiation.

JSP Expression Language JSP became beautiful after this The motivation is to lose scriplets whatsoever. Also non java programmers should be able to use it easily, because it is just an expression language. It was inspired by xpath and java script except it is much easier than any of them

EL syntax Expressions appear between ${ and }. Note that ${ and } may contain whole expressions, not just variable names E.g., ${myExpression + 2} Access JavaBean properties using. (dot) ${book.title} translates to book.getTitle() Access to Array and Collection elements using collection[] Access to a Map value by key using map[“key”]

EL syntax EL searches each scope area if a scope isn’t specified Specific scope areas can be used: ${pageScope.title} ${requestScope.title} ${sessionScope.title} ${applicationScope.title} ${duck.beakColor} can resolve to ((Duck) pageContext.getAttribute(”duck”)).getBeakColor() Automatic Casting, wow

EL Operators Arithmetic +, -, *, / (or div), % (or mod) – note on XPath Relational == (or eq), != (or ne), < (or lt) > (or gt), = (or ge) Logical && (or and), || (or or), ! (or not) Validation empty null values Collections or Arrays that are empty Strings that evaluate to “”

EL Operators (Examples) Arithmetic${age + 3} Comparisons${age > 21} Equality checks${age = 55} Logical operations${young or beautiful} Emptiness detection${empty a} ‘a’ is empty String (“”), empty List, null, etc. Useful for ${empty param.x}

Implicit objects in EL Param and paramvalues Access HTTP request parameters Example: ${param.password} Header and headervalues Request header information Example: ${header[“User-Agent”]} Initparam (for the context init parameters of the webapp) Example: ${pageContext.request.remoteUser} Cookies Example: ${cookie.crumb}

EL: Uses JSTL 1.0 introduced the EL, but it could be used only within tags. In JSP 2.0, it can be used almost anywhere Hi, ${user}. You are years old.

JSTL JSP Standard Tag Library Set of tags that should be available in all compliant JSP containers Promotes rapid application development at the web page layer

Why JSTL? A big reason is that writing your own custom actions, or tags, can be a pain There was lots of reinventing the wheel going on, for tasks like displaying a date in a special format Many open source libraries sprung up, but there was still no standard This fueled the fire behind JSTL

JSTL: Features Control flow Iteration, conditions URL management Retrieve data, add session IDs Text formatting and internationalization Dates and numbers Localized messages XML manipulation XPath, XSLT Database access Queries, updates (you do not need to write java any more )

JSTL: Libraries Library featuresRecommended prefix Core (control flow, URLs, variable access) c Text formattingfmt XML manipulationx Database accesssql

Managing variables Outputting values with EL Storing data <c:set var=”user” scope=”session”> // arbitrary text Note the use of “var” and “scope”: a JSTL convention

Iteration A loop with a start, end, and step (typical for statement) <c:forEach var="name" varStatus="name" begin="expression" end="expression" step="expression"> body content A loop using an Iterator for a collection <c:forEach var="name" items="expression" varStatus="name" begin="expression" end="expression" step="expression"> body content

Example Value Square <c:forEach var="x" begin="0" end="10" step="2"> ${x} ${x * x}

Conditional logic Conditional evaluation a equals b Mutually exclusive conditionals a equals b a equals c I don’t know what ’a’ equals.

Example This is an insecure Web session. This is a secure Web session. You are using an unrecognized Web protocol. How did this happen?!

URL management Retrieving data <c:import var=”cnn” url=” ”/> Data exposed as String or Reader All core URLs supported (HTTP, FTP, HTTPS with JSSE) Local, cross-context imports supported Printing URLs Redirection

Text formatting Locale-sensitive formatting and parsing Numbers Dates Internationalization Message bundles Message argument substitution “Hi {0}. I would like to {1} your money today. I will use it to buy myself a big {2}.”

Example ${blogEntry.title} ${blogEntry.text} [Posted <fmt:formatDate value="${blogEntry.created}" pattern="h:mm a zz"/>]

database manipulation Queries (and ResultSet caching) Updates / inserts Transactions ( ) Parametric ( PreparedStatement ) argument substitution ( ) DataSource-based connection management …

XML manipulation Use of XPath to access, display pieces of XML documents Chaining XSLT transformations

Why Not XSLT JSTL integrates XPath with convenient, standard access to Java/JSP code. E.g., parse an article URL out of a document, then follow the URL and parse its contents. JSP/JSTL may be more familiar and convenient for simple tasks. Functional versus imperative programming

Adding New Tag There are two ways to add news tags Extend the JSTL and override methods Define Tag files (This is much easier, so we gone study this )

Tag Files Solve difficulty of reusing text/HTML within a tag. And makes it much easier to write simple tags, since you can do so in JSP instead of Java. Stand-alone file with directive instead of traditional directive.

Tag Files Name IQ ${i.fullName} ${i.IQ}

Using new Tag.... Your shopping cart: Your wish list: Things we want you to buy: