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.

Slides:



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

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 web applications
Java Script Session1 INTRODUCTION.
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.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Java II--Copyright © Tom Hunter. J2EE JSP Custom Tag Libraries.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
The Web Warrior Guide to Web Design Technologies
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Advanced Java Server Pages An more detailed look at JSPs.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
JavaServer Faces. Objectives To implement dynamic web pages with JavaServer Faces (JSF) technology To learn the syntactical elements of JavaServer Faces.
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
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
Generate Dynamic Content On Cache Server Master’s Project Proposal by Aparna Yeddula.
JSP Java Server Pages Reference:
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.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
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.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
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.
JSP Standard Tag Library
Java Beans.
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:
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.
JSP Java Server Pages Softsmith Infotech.
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)
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
® 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.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
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
JavaScript - A Web Script Language Fred Durao
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
JSP Tag Libraries Lec Last Lecture Example We incorporated JavaBeans in “Course Outline” Example But still have to write java code inside java.jsp.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
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.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
© 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.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
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.
 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.
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.
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.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
J2EE JSP Custom Tag Libraries 1 3 JSP: Custom Tag Libraries.
Scripted Page Web App Development (Java Server Pages)
MSIS 655 Advanced Business Applications Programming
Java Server Pages.
Presentation transcript:

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 to a JSP engine at translation time, and enable application functionality to be invoked without the need towrite Java code in JSP scriptlets. Well-designed tag extension libraries can enable application functionality to be invoked without the appearance of programming.

Tag Extensions Basics Consider the action provided by the JSP specification. This tag dispatches the current request to another page in the current web application. It can be invoked with the following syntax: We can also to add additional parameters to the request before forwarding with an extended usage of, which nests one or more tags within the tag:

Tag Extensions Basics Tag extensions allow a vast range of new functionality to be added to the JSP language and they can be invoked in a similarly intuitive way. For example, I could create a tag named, specify what attributes and subtags, if any, it requires, and implement it to perform a custom action before forwarding. Not only can this be added simply into the web page, it enforces separation of code and presentation, decouples the call from the class that implements the functionality associated with the tag, and can be simply incorporated into a design tool.

Tag Extensions Basics The key concepts in tag extensions are: ❑ Tag name: A JSP tag is uniquely identifed by a combination of prefix (in this case jsp ), and suffix (in this case forward ), separated by a colon. ❑ Attributes: Tags may have attributes, which use the XML syntax for attributes. The tag above has one attribute ( page ), while the attribute has two ( name and value ). Attributes may be required or optional.

Tag Extensions Basics ❑ Nesting: Note how the subtag is used in the second example above. Tag extensions can detect nested tags at runtime and cooperate. A tag directly enclosing another tag is called the parent of the tag it encloses: in the example above, the tag is the parent of the tag. ❑ Body content: This is anything between the start and end elements in a JSP tag, excluding subtags. A tag extension can access and manipulate its body content. Neither the n or tags require body content. We will see later an example of a tag that can reverse its body content.

Tag Extensions Basics Typical uses of tag extensions are: ❑ To conceal the complexity of access to a data source or enterprise object from the page (possibly, the page author, who may not be experienced with enterprise data) ❑ To introduce new scripting variables into the page ❑ To filter or transform tag content, or even interpret it as another language ❑ To handle iteration without the need for scriptlets

A Simple Tag Before we look at the API supporting tag extensions and the supporting infrastructure in detail, let's implement a simple tag. The simplest case is a tag without attributes or body content, which outputs some HTML. We'll add some dynamic content to prove that the tag is alive. Say we want to see the following output: Hello world. My name is and it is now We'll call our simple tag hello. Here's how we might use it in a JSP. I've named this simple example hello.jsp. The first line is a declaration used to import the tag library, which we will discuss in detail later:

A Simple Tag First custom tag This is static output. This is static output again.

A Simple Tag package tagext; import java.io.IOException; import java.util.Date; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; // Implementation of a tag to generate a single piece of HTML public class HelloTag extends TagSupport { // This method will be called when the JSP engine encounters the start // of a tag implemented by this class public int doStartTag() throws JspTagException { // This return value means that the JSP engine should evaluate // the contents and any child tags of this tag return EVAL _ BODY _ INCLUDE; }

A Simple Tag // This method will be called when the JSP engine encounters the end // of a tag implemented by this class public int doEndTag() throws JspTagException { String dateString = new Date().toString(); try { pageContext.getOut().write("Hello world. "); pageContext.getOut().write("My name is " + getClass().getName() + " and it's " + dateString + " "); } catch (IOException ex) { throw new JspTagException ("Fatal error: hello tag could not write to JSP out"); } // This return value means that the JSP engine should continue to // evaluate the rest of this page return EVAL _ PAGE; } } // class HelloTag

A Simple Tag <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" " _ 1 _ 1.dtd"> examples Simple example library. hello tagext.HelloTag JSP Simple example

A Simple Tag Once everything is in the right place (see Getting it running below), hello.jsp should look like this in your browser:

Java Bean Definition: What is a Bean? If you have used Delphi, or Visual Basic, you are already familiar with the notion of a bean. The idea is the same; the programming language is different. A Java Bean is a reusable software component that works with Java. More specifically: a Java Bean is a reusable software component that can be visually manipulated in builder tools. Definition: A Java Bean is a reusable software component that can be visually manipulated in builder tools. To understand the precise meaning of this definition of a Bean, clarification is required for the following terms:  Software component  Builder tool  Visual manipulation

Reusable Software Components Reusable software components are designed to apply the power and benefit of reusable, interchangeable parts from other industries to the field of software construction. Other industries have long profited from reusable components. Reusable electronic components are found on circuit boards. A typical part in your car can be replaced by a component made from one of many different competing manufactuers. Lucrative industries are built around parts construction and supply in most competitive fields. The idea is that standard interfaces allow for interchangeable, reusable components.

Reusable Software Components Reusable software components can be simple like familiar push buttons, text fields list boxes, scrollbars, dialogs, for example Button Beans

Reusable Software Components Slider Beans Spinbutton Beans

Java Beans With Beans, you can purchase custom components for Java from third parties. You can also purchase builder tools or application contruction programs supporting Beans Application construction tools let you you to build Java applications by visually selecting components from pallets, panels, or menus, drop them into a form, or client window, and hook up events to event handlers using the mouse as your primary input mechanism. Components can be nested and arbitrarily complex. For example, a calculator built from components becomes, itself, a component. Custom-built components are easily added to builder tool palettes. More complex components include barcharts,

Java Beans