J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
Advertisements

J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
Enterprise Java: Developing JSP Custom Tag Libraries Developing JSP Custom Tag Libraries O'Reilly Conference on Enterprise Java, March 2001.
JSP Custom Tags Keyton Weissinger Key Focus, Inc. 27 March 2001 OReilly Conference on Enterprise Java Santa Clara, CA.
5 Copyright © 2005, Oracle. All rights reserved. Accessing the Database with Servlets.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
9 Copyright © 2005, Oracle. All rights reserved. Modularizing JavaServer Pages Development with Tags.
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
JSP and Servelets.
JSP and web applications
CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
Creating Custom JSP Tag Libraries Taken from Core Servlets and JavaServer Pages from Prentice.
Chapter 10 Ch 1 – Introduction to Computers and Java Streams and File IO 1.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
Java Server Pages (JSP)
Java Servlets Java Server Pages (JSP)
© Yaron Kanza Advanced Java Server Pages Written by Dr. Yaron Kanza, Edited by permission from author by Liron Blecher.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 24: Servlets Outline 24.1 Introduction 24.2 Servlet Overview and Architecture Interface.
JavaServerPages Some examples. About JSP Java server pages are a combination of html (or xml), java code appearing within tagged regions, and structures.
Java II--Copyright © Tom Hunter. J2EE JSP Custom Tag Libraries.
Advanced Java Server Pages An more detailed look at JSPs.
JSP Tag Extensions And Java Bean. JSP Tag Extensions Tag extensions look like HTML (or rather, XML) tags embedded in a JSP page. They have a special meaning.
Java Server Pages by Jon Pearce. JSP Documents JSP docs are XHTML Documents containing: –Fixed-Template Data: FTD HTML Components XML markup –JSP Components:
Generate Dynamic Content On Cache Server Master’s Project Proposal by Aparna Yeddula.
Object-Oriented Enterprise Application Development JavaServer Pages Tag Libraries.
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.
Basic Elements JSP For a Tutorial, see:
Examples of Using Servlets and JSP Representation and Management of Data on the Internet.
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.
Chapter 111© copyright Janson Industries 2011 Custom Tags ▮ Tag Handlers ▮ XML ▮ Tag Libraries ▮ Web Deployment Descriptor.
1 JSP 1.2 Custom Tags. 2 Agenda ● What is and why custom tags? ● Components that make up custom tag architecture ● How to create custom tags? ● How does.
Custom Tags1 Usage Rules PowerPoint slides for use only in for-credit courses at degree-granting institutions Slides can be modified.
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.
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,
1 JSP with Custom Tags Blake Adams Introduction Advanced Java Server Pages – Custom Tags Keyterms: - Tag Library Descriptor(TLD) - Tag Libraries.
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.
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.
CS320 Web and Internet Programming Custom Tag Library Chengyu Sun California State University, Los Angeles.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
JSP Custom Tags. Prerequisites Servlet API Mapping to JSP implicit objects JavaServer Pages Basic syntax Implementation via servlet API XML.
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.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
Java Web 应用开发: J2EE 和 Tomcat 蔡 剑, Ph.D.. 本讲内容 Web 层技术 (III) Custom Tags JSP and XML JSTL.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
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.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
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.
CS3220 Web and Internet Programming Custom Tag Library
Pre-assessment Questions
JSP Basic Elements For a Tutorial, see:
JSP Revisited Instructors: Geoffrey Fox and Bryan Carpenter
JSP Custom Tags Welcome.
Presentation transcript:

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento JSP Tag Extension

J0 2 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento First custom tag This is static output HELLO THERE This is static output a JSP custom tag hello.doStartTag() hello.doEndTag()

J0 3 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento package jsptags; import java.io.IOException; import java.util.Date; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; public class HelloTag extends TagSupport { public int doStartTag() throws JspTagException { try { pageContext.getOut().write("Start tag found here "); } catch (IOException e) { throw new JspTagException("Fatal error: could not write to JSP out"); } return EVAL_BODY_INCLUDE; // return SKIP_BODY; } a JSP custom tag

J0 4 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento … public class HelloTag extends TagSupport { … public int doEndTag() throws JspTagException { try { pageContext.getOut().write("End tag found "); } catch (IOException e) { throw new JspTagException("Fatal error: could not write to JSP out"); } return EVAL_PAGE; // return SKIP_PAGE; } a JSP custom tag

J0 5 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento Javax.servlet.jsp.tagext.Tag interface TagPagina JSP setPageContext(pageContext) setParent(enclosingTag) setAttribute1(pageContext) doStartTag() doEndTag() release()

J0 6 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento Class Diagram API

J0 7 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento First custom tag This is static output HELLO THERE This is static output a JSP custom tag hello.doInitBody() hello.doEndTag() hello.doStartTag() hello.doAfterBody()

J0 8 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento package jsptags; … public class HelloTag extends BodyTagSupport { public int doStartTag() throws JspTagException { … } public void doInitBody() throws JspTagException { try { pageContext.getOut().write("Init Body "); } catch (IOException e) { throw new JspTagException("Fatal error: could not write to JSP out"); } a JSP custom tag

J0 9 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento public int doAfterBody() throws JspTagException { try { pageContext.getOut().write("After Body "); } catch (IOException e) { throw new JspTagException("Fatal error: could not write to JSP out"); } return EVAL_BODY_TAG; // return SKIP_BODY; } */ public int doEndTag() throws JspTagException { … } a JSP custom tag

J0 10 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento Javax.servlet.jsp.tagext.BodyTag interface TagPagina JSP setPageContext(pageContext) setParent(enclosingTag) setAttribute1() doStartTag() setBodyContent(out) release() PageContext pushBody() doInitBody() doEndTag() doAfterBody() popBody()

J0 11 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento import java.io.IOException; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; public class ReverseTag extends BodyTagSupport { public int doEndTag() throws JspTagException { BodyContent bodyContent = getBodyContent(); if (bodyContent != null) {// Do nothing if there was no body content StringBuffer output = new StringBuffer(bodyContent.getString()); output.reverse(); try { bodyContent.getEnclosingWriter().write(output.toString()); } catch (IOException ex) { throw new JspTagException("Fatal IO error"); } } return EVAL_PAGE; } reversing body content

J0 12 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento structure of the war file hello hello.jsp META-INF WEB-INF MANIFEST.MF web.xml tldsclasses hello.tldHelloTag.class A war file is a jar file with special directories and a file named web.xml in the WEB-INF directory

J0 13 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" " examples Simple example library. reverse tagext.ReverseTag JSP Simple example TLD

J0 14 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento tagext Tag extensions examples 0 /hello /WEB-INF/tlds/hello.tld web.xml