® IBM Software Group © 2007 IBM Corporation JSP Tag Files 4.1.0.3.

Slides:



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

8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Java Script Session1 INTRODUCTION.
CS4273: Distributed System Technologies and Programming I Lecture 11: JavaServer Pages (JSP)
Java II--Copyright © Tom Hunter. J2EE JSP Custom Tag Libraries.
DT211/3 Internet Application Development
Generate Dynamic Content On Cache Server Master’s Project Proposal by Aparna Yeddula.
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,
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.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
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.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
Java Server Pages CS-422. What are JSPs A logical evolution of java servlets –most servlets dynamically create HTML and integrate it with some computational.
Netbeans – jsp.zip Introduction to JSP Netbeans – jsp.zip.
Java for the WWW November 2012Slide Tag Libraries What are they? –Custom libraries Custom tags – see examples in following slides.
OOSSE - OO Review Review session A review of other OO technologies and may be useful for exam (not required for assignment) OO web development philosophy.
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.
® IBM Software Group © 2007 IBM Corporation JSP Custom Tags
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.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
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.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
Web Server Programming 3. Server side includes. HTML+ (‘hole’) technologies Uses ‘HTML+”, HTML (or XML) extended with code. Very many different varieties.
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
COMP 321 Week 11. Overview Lab 8-1 Solution Tag Files Custom Tags Web Application Deployment.
Chapter 7 Using Custom Tag Libraries and the JSP Standard Tag Library.
SE-2840 Dr. Mark L. Hornick 1 Java Server Pages. HTML/JSPs are intended to be used as the views in an MVC- based web application Model – represents an.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
JSP Tag Libraries Lec Last Lecture Example We incorporated JavaBeans in “Course Outline” Example But still have to write java code inside java.jsp.
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Java Server Pages (JSP)
Java Server Pages An introduction to JSP. Containers and Components Several clients – one system.
CS320 Web and Internet Programming Custom Tag Library Chengyu Sun California State University, Los Angeles.
CS-4220 Dr. Mark L. Hornick 1 Java Server Pages. HTML/JSPs are intended to be used as the views in an MVC- based web application Model – represents an.
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.
CSC 2720 Building Web Applications JavaServer Pages (JSP) JSP Directives and Action Elements.
JSP. Types of JSP Scripting Elements Expressions of the form, which are evaluated and inserted into the servlet's output. Scriptlets of the form, which.
Web Technologies Java Beans & JSP By Praveen Kumar G.
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
© 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.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
DT228/3 Web Development JSP: Actions elements and JSTL.
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.
J2EE JSP Custom Tag Libraries 1 3 JSP: Custom Tag Libraries.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
CS320 Web and Internet Programming Custom Tag Library Chengyu Sun California State University, Los Angeles.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
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.
Developing JavaServer Pages
Java Servlets By: Tejashri Udavant..
Knowledge Byte In this section, you will learn about:
Pre-assessment Questions
Invoking Java Code from JSP
Presentation transcript:

® IBM Software Group © 2007 IBM Corporation JSP Tag Files

2 After completing this unit, you should be able to:  Describe the use of JSP tag files  Call a tag file from a JSP  Pass body content, parameters and fragments to a tag file  Create a tag file and use the tag file directives  Package a tag file After completing this unit, you should be able to:  Describe the use of JSP tag files  Call a tag file from a JSP  Pass body content, parameters and fragments to a tag file  Create a tag file and use the tag file directives  Package a tag file Unit objectives

3 Overview of Tag Files  Another way to build custom actions  Tag files are JSPs with.tag or.tagx extensions  Allows non-Java developers to create reusable custom actions  Are automatically interpreted by the JSP container when placed in the /WEB-INF/tags folder  Custom action name is the same as the tag file name  Can be further organized in sub-folders of /WEB-INF/tags  Tag files are separate files that are called from JSPs Caller JSP …body content… TagFile2.tag TagFile1.tag

4 Calling a Tag File from a JSP  Resembles the invocation of a custom action  Tag files are automatically compiled into SimpleTags  More powerful than a that can only accept string parameters in the request  The tag file has access to implicit objects  The tag file can be passed  Body content: content in between the begin and end tag  Parameters  Fragments: individually named body content  For example to call details.tag from a caller JSP

5 Body Content from Caller JSP  Body Content can be: scriptless, tagdependent or empty  Tag files can use to use the body content  Caller JSP Uppercase this text  toUpper.tag (Tag file) Body Content

6 Parameters from Caller JSP  Passed as attributes to the tag file  Matches an attribute, with the same name, in the tag file  Can be a dynamic list of attributes  Handled in the tag file by a Map, thus order is not guaranteed  Can be mixed with defined attributes <info:details dyna1="first" loanedCopy="${item}" dyna2="second"/> defined parameter mixed in with 2 dynamic parameters parameter

7 Fragments from Caller JSP  Enable the calling page to pass in named fragments of body content  is used to define the main body content Welcome to the IBM Library System System has ${library.size} books ${item.title} ${item.author}

8 Tag Directive in Tag File  Attribute list for the directive  display-name  body-content: empty, scriptless or tagdependent  dynamic-attributes: name of the attribute map  small-icon  large-icon  description  example  language: scripting language  import: list of imports  pageEncoding  isELIgnored: true of false  For example

9 Attribute Directive in Tag File  Maps incoming parameters to variables  Attribute list for the directive  name  required: true or false  fragment: true or false  rtexprvalue: true or false  type: type of the attribute  description  For example attribute name="loanedCopy" required="true" type="com.ibm.library.model.LoanedCopy"%>  Dynamic attribute map, is defined in the tag directive ${element.key} : ${element.value}

10 Variable Directive in Tag File  Exposes variables to the calling page  A name can be given to the attribute or can be assigned from an attribute  if assigned from an attribute an alias needs to be defined to reference the attribute within the tag file  Attribute list for the directive  name-given or name-from attribute, with an alias  variable-class  scope: AT_BEGIN, AT_END or NESTED  description  For example 

11 Implicit Objects Available in a Tag File  Collection of objects available to the tag file  request: ServletRequest or HttpServletRequest  response: ServletResponse or HttpServletResponse  jspContext: JspContext for this tag file  session: HttpSession  application: ServletContext  out: JspWriter  config: ServletConfig

12 Example of Calling a Tag File  Tag invocation in ListItems.jsp (Caller JSP)  Tag definition in details.tag (Tag file) attribute name="loanedCopy" required="true" type="com.ibm.library.model.LoanedCopy"" %> Times Renewed = ${loanedCopy.timesRenewed}

13 Tag File with Body Content and a Fragment  Tag files can be passed fragments and evaluate the separately, using  Calling JSP Fragment 1 Body content  fragmentTest.tag

14 Tag File Packaging  A tag file is recognized by the container if placed in /WEB- INF/tags/ folder  Tag file does not need TLD  At tag file placed in the /META-INF/tags folder of a JAR file requires a TLD  The JAR file is placed in the /WEB-INF/lib folder  Tags can also be packaged as compiled Java classes

15 Checkpoint 1.Where can a tag file need to be placed to be automatically picked up by the JSP container? 2.Why use a tag file instead of writing a custom tag handler?

16 Checkpoint solutions 1./WEB-INF/tags 2.Allows non-Java developers to create reusable custom actions. Also externalizes any HTML and layout information that may creep into a tag handler class.

17 Having completed this unit, you should be able to:  Describe the advantages of using JSP custom tags  List the major steps in developing and using JSP custom tags  Develop basic tag handler classes to implement JSP custom tags  Create and modify taglib descriptor files  Package JSP taglib implementation classes and taglib descriptor files  Understand the uses of the JSTL  Name some of the tags included in the JSTL and their purposes  Create and call a tag file from a JSP Having completed this unit, you should be able to:  Describe the advantages of using JSP custom tags  List the major steps in developing and using JSP custom tags  Develop basic tag handler classes to implement JSP custom tags  Create and modify taglib descriptor files  Package JSP taglib implementation classes and taglib descriptor files  Understand the uses of the JSTL  Name some of the tags included in the JSTL and their purposes  Create and call a tag file from a JSP Unit summary