Services. Custom Tag Libraries. Today. Web Development. Role-Based. Development. Code Reuse. Tag Libraries Custom Tags. Tag Lifecycle.



Similar documents
JSP Java Server Pages

Web Application Architecture (based J2EE 1.4 Tutorial)

Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache.

In this chapter, we lay the foundation for all our further discussions. We start

JSP. Common patterns

DTS Web Developers Guide

CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012

Web Programming II JSP (Java Server Pages) ASP request processing. The Problem. The Problem. Enterprise Application Development using J2EE

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

Controlling Web Application Behavior

Web Container Components Servlet JSP Tag Libraries

Exam Prep. Sun Certified Web Component Developer (SCWCD) for J2EE Platform

Building Web Applications, Servlets, JSP and JDBC

PowerTier Web Development Tools 4

Glassfish, JAVA EE, Servlets, JSP, EJB

Complete Java Web Development

SSC - Web development Model-View-Controller for Java web application development

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

CrownPeak Java Web Hosting. Version 0.20

Creating Java EE Applications and Servlets with IntelliJ IDEA

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Getting Started with Web Applications

Web Application Programmer's Guide

CS506 Web Design and Development Solved Online Quiz No. 01

Understanding class paths in Java EE projects with Rational Application Developer Version 8.0

Mastering Tomcat Development

Java Application Developer Certificate Program Competencies

Specialized Programme on Web Application Development using Open Source Tools

Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat

JBoss Portlet Container. User Guide. Release 2.0

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

What Is the Java TM 2 Platform, Enterprise Edition?

Enterprise Application Development In Java with AJAX and ORM

Introduction to J2EE Web Technologies

A Guide to Understanding Web Application Development Corey Benson, SAS Institute, Inc., Cary, NC Robert Girardin, SAS Institute, Inc.

WebSphere Training Outline

Web Programming with Java Servlets

Developing Web Applications using JavaServer Pages and Servlets

SESM Tag Library. Configuring a Tag Library APPENDIX

An introduction to creating JSF applications in Rational Application Developer Version 8.0

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

WebSphere v5 Administration, Network Deployment Edition

IBM Rational Rapid Developer Components & Web Services

Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga

Developing XML Solutions with JavaServer Pages Technology

Enterprise Applications

Specialized Programme on Web Application Development using Open Source Tools

Appendix A: Final Mock Exam

Course Name: Course in JSP Course Code: P5

Web Service Development Using CXF. - Praveen Kumar Jayaram

2.8. Session management

Net-WMS FP Net-WMS SPECIFIC TARGETED RESEARCH OR INNOVATION PROJECT. Networked Businesses. D.8.1 Networked architecture J2EE compliant

NetBeans IDE Field Guide

Java 2 Platform, Enterprise Edition (J2EE) Bruno Souza Java Technologist, Sun Microsystems, Inc.

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

ArpViewer Manual Version Datum

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

Web Frameworks and WebWork

White Paper. JavaServer Faces, Graphical Components from Theory to Practice

Crystal Reports for Borland JBuilder

CA Identity Manager. Glossary. r12.5 SP8

JBoss SOAP Web Services User Guide. Version: M5

MDA Overview OMG. Enterprise Architect UML 2 Case Tool by Sparx Systems by Sparx Systems

Research Article. ISSN (Print) *Corresponding author Lili Wang

Web Applications. Originals of Slides and Source Code for Examples:

ACM Crossroads Student Magazine The ACM's First Electronic Publication

Creating a Java application using Perfect Developer and the Java Develo...

Java E-Commerce Martin Cooke,

Web Applications. For live Java training, please see training courses at

As you learned about in Chapter 1, WebSphere Application Server V6 supports the

Core Java+ J2EE+Struts+Hibernate+Spring

Agenda. Summary of Previous Session. Application Servers G Session 3 - Main Theme Page-Based Application Servers (Part II)

Web Application Development

Web Development in Java

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

Crystal Reports for Eclipse

Learning GlassFish for Tomcat Users

Install guide for Websphere 7.0

Model-View-Controller: A Design Pattern for Software. June 2004

Tutorial: Building a Web Application with Struts

Oracle WebLogic Server

C/S Basic Concepts. The Gartner Model. Gartner Group Model. GM: distributed presentation. GM: distributed logic. GM: remote presentation

Oracle WebLogic Server 11g: Administration Essentials

Core J2EE Patterns, Frameworks and Micro Architectures

EVALUATION OF SERVER-SIDE TECHNOLOGY FOR WEB DEPLOYMENT

Virtual Credit Card Processing System

Policy Guide Access Manager 3.1 SP5 January 2013

Oracle WebLogic Server

Building and Using Web Services With JDeveloper 11g

WIRIS quizzes web services Getting started with PHP and Java

Spring Security SAML module

Apache Jakarta Tomcat

Transcription:

JSP, and JSP, and 1 JSP, and Custom Lecture #6 2008 2 JSP, and JSP, and interfaces viewed as user interfaces methodologies derived from software development done in roles and teams role assignments based on competences Teams formulated to encompass all roles Team leaders divide work into packages and plan projects Unique competences often timeshared between teams Team size adapted to project size and time / cost restraints JSP, and Typical Roles JSP, and Scenario Project Leader assembles system requirements Designer / Systems Architect Systems Developer / Programmer Interface / Developer Database Developer Graphics Artist Usability Specialist Team / Project Leader Documentation Specialist Systems Designer / Architect designs system Database Developer designs and implements database Systems Developer / Programmer develops database access and logic components Interface / Developer develops user interfaces (web pages) Graphics Artist creates illustration and web site graphics Usability Specialist verifies web site usability features Documentation Specialist documents all technical solutions What (if any) of these can be done in parallel?

JSP, and JSP, and Motivations for Use of existing software, or software knowledge, to build new software Supports interface abstraction, modularity, loose coupling, information hiding, and separation of concerns Code is reused as - replicated code (copy and paste) - templates - generated code - functions / procedures - modules - libraries Expensive to reinvent the wheel The wheel not always round in subsequent versions... Often (much) faster to built on standardized solutions Complex implementations will contain bugs Bugs and security vulnerabilities addressed faster by specialized tools manufacturers Module interfaces abstract implementation complexity JSP, and in JSP JSP, and Code and script snippets imported (scriptlets) Code library use in JSP pages (classes in JARs) Reuse of logic layer components (beans and EJBs) Tag libraries (classes with tag interfaces) Introduced in JSP 1.1 Allows users to create their own JSP tags Commonly referred to as custom tags Emphasizes role-based development methodology (separates creator of tag from user of tag) Integrated in JSP (can alter JSP body response stream) Used to encapsulate complex logic and reuse code JSP, and JSP, and Tag Interface A Java class implementing the Tag interface (boilerplate implementation classes available) Defines tag name, tag attributes & tag body interpretation Specify a tag description in a XML-based descriptor file Included in JSP using the taglib directive Tags may control JSP processing Implement directly or extend TagSupport / BodyTagSupport public interface Tag extends JspTag Tag getparent (); void setparent (Tag t); void setpagecontext (PageContext pc); void release (); int doendtag (); int dostarttag ();

JSP, and IterationTag Interface JSP, and BodyTag Interface Implement directly or extend TagSupport / BodyTagSupport Used to iterate body evaluation (repeats until doafterbody() returns SKIP BODY) public interface IterationTag extends Tag int doafterbody (); Implement directly or extend BodyTagSupport Used to gain access to body content public interface BodyTag extends IterationTag int doinitbody (); int setbodycontent (BodyContent b); JSP, and SimpleTag Interface JSP, and Introduced in JSP 2.0 Implement directly or extend SimpleTagSupport public interface SimpleTag extends JspTag JspTag getparent (); void setparent (JspTag t); void setjspbody (JspFragment body); void setjspcontext (JspContext pc); void dotag (); XML-based configuration file Provides a mapping from tag names to tag Java classes Contains tag library information and tag descriptions Tag descriptions direct how the tag is utilized (by the JSP engine, include tag body etc) Required, one per tag library JSP, and Content JSP, and name - tag alias for use in JSP (coupled to tag library namespace) tagclass - fully qualified implementation class name attribute - tag attributes (optional) (used as tag parameters, values delivered as Strings) - name - attribute name - required - attribute required to process tag flag - rtexprvalue - attribute value from JSP expression flag info - descriptive information about tag (optional) body-content - tag body processing directives (optional) - EMPTY - no tag body - JSP - body contains JSP - TAGDEPENDENT - tag processes body itself 1 - coding a tag library & writing a descriptor - developing JSP pages that uses the tag library 2 Translation - compile time - tags and JSP translated to servlets (tag calls inserted) 3 Evaluation - request time - tag is loaded and methods are called

JSP, and Tag JSP, and Tag Translation Can be done in a separate environment (only requires access to the J2EE environment) Tag development like any other Java development Tags are exported in a JAR file Tag library descriptor included in JAR file (in the META-INF directory) Compile time 1 A call to dostarttag() is inserted in Servlet 2 Tag body is translated (JSP inserted in Servlet) 3 A call to doendtag() is inserted in Servlet JSP, and Tag Evaluation JSP, and Tag Method Return Values Request time 1 setpagecontext() called, page context provided 2 setparent() called, page hierarchy established (used for nested tags) 3 setattribute () is called for attributes 4 dostarttag() called, return value directs processing 5 Tag body processed (if so instructed by dostarttag()) 6 doendtag() is invoked, return value directs processing 7 release() is called to release tag resources (so that tag objects can be reused by thread pools) dostarttag() - EVAL BODY INCLUDE - process tag body - EVAL BODY BUFFERED - tag processes body - SKIP BODY - do not process tag body doafterbody() (IterationTag) - EVAL BODY AGAIN - repeat tag body evaluation - SKIP BODY - do not repeat tag body evaluation doendtag() - EVAL PAGE - process rest of JSP - SKIP PAGE - do not process rest of JSP JSP, and Tag Example JSP, and Example public class SimpleHelloWorldTag extends TagSupport //--------------------------------------------------------- public int doendtag () throws JspException try JspWriter out = pagecontext.getout(); out.print("(simple) Hello world!"); catch (IOException e) throw new JspException(e.getMessage()); return Tag.EVAL_PAGE; <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"> <taglib> <tlib-version>1.0</tlib-version> <jsp-version>1.2</jsp-version> <short-name>lecture06</short-name> <uri>taglibs/lecture06</uri> <description> lecture06 taglib </description> <tag> <name>simplehelloworld</name> <tag-class>lecture06.tags.simplehelloworldtag</tag-class> <body-content>empty</body-content> </tag> </taglib>

JSP, and Tag JSP Example JSP, and web.xml <%@ taglib uri="/web-inf/lecture06-taglib.tld" prefix="lecture06" %> <html> <body>... <lecture06:simplehelloworld/> application configuration file Specific to Tomcat Maps relative tag descriptor URIs to local filenames Optional (specify descriptor path in taglib directive)... </body> <html> <taglib> <taglib-uri>lecture06-taglib.tld</taglib-uri> <taglib-location>/web-inf/lecture06-taglib.tld</taglib-location> </taglib> JSP, and Summary JSP, and Tab libraries are used to extend the JSP tag set Very powerful way to reuse Java code in JSP Custom tags can be used as any JSP tag Tag behavior determined by tag developer Custom tags well suited to hide large logic segments Relational Databases & JDBC Custom tags are never visible to web clients