 2002 Prentice Hall. All rights reserved. JavaServer Pages.

Slides:



Advertisements
Similar presentations
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Advertisements

Java Server Pages (JSP)
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Michael Brockway Application Integration JavaServer Pages l Introduction & Overview l Implicit Objects l Scripting l Standard Actions l Directives l References.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Chapter 25: JavaServer Pages Outline 25.1 Introduction 25.2 JavaServer Pages Overview 25.3 First JavaServer Page Example 25.4 Implicit Objects 25.5 Scripting.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Java Server Pages by Jon Pearce. JSP Documents JSP docs are XHTML Documents containing: –Fixed-Template Data: FTD HTML Components XML markup –JSP Components:
 2002 Prentice Hall. All rights reserved. 1 Chapter 6 – Introduction to the Common Gateway Interface (CGI) Outline 6.1 Introduction 6.2 Client and Web.
Pertemuan 10 Pemrograman JSP Matakuliah: T0053/Web Programming Tahun: 2006 Versi: 2.
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,
Three types of scripting elements: 1.Expressions 2.Scriptlets 3.Declarations Scripting elements.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems JavaServer Pages (JSP)
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.
JavaServer Pages TM Introduce by
CS 174: Web Programming February 26 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
 2004 Prentice Hall, Inc. All rights reserved. Chapter 37 - JavaServer Pages (JSP): Bonus for Java Developers Outline 37.1 Introduction 37.2 JavaServer.
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
11. Java-Based Web: JSP, JSF. 2 Motto: Rule 1: Our client is always right Rule 2: If you think our client is wrong, see Rule 1. - Anonymous.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 25: JavaServer Pages Outline 25.1 Introduction 25.2 JavaServer Pages Overview 25.3 First JavaServer.
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.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Introducing.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Introduction to Java Server Pages (JSPs) Robert Thornton.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 25: JavaServer Pages Outline 25.1 Introduction 25.2 JavaServer Pages Overview 25.3 First JavaServer.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 31 - JavaServer Pages (JSP): Bonus for Java™ Developers Outline 31.1 Introduction 31.2 JavaServer.
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.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Chapter 10 Overview of JSP Technology. Understanding the need for JSP JSP technology enables to mix regular, static HTML with dynamically generated content.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Java Stream 1 Unit 10 – Java Server Pages Introduction A First JavaServer Page Example Implicit Objects Scripting Standard Actions Directives Custom Tag.
intro JSP Pertemuan 8 Matakuliah: Web Programming Tahun: 2009.
 2005 Pearson Education, Inc. All rights reserved JavaServer Pages (JSP)
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
1 Introduction to XHTML: Part 1 Outline Introduction Elements and Attributes Editing XHTML Common Elements W3C XHTML Validation Service Headers Linking.
Jsp (Java Server Page) Is a server side program.
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 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 31.1 Reviewing the Bookstore Application 31.2.
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.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 25: JavaServer Pages Outline 25.1 Introduction 25.2 JavaServer Pages Overview 25.3 First JavaServer.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
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.
 2002 Prentice Hall. All rights reserved. Chapter 10: JavaServer Pages Outline 10.1 Introduction 10.2 JavaServer Pages Overview 10.3 A First JavaServer.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
 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 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.
OV Copyright © 2008 Element K Content LLC. All rights reserved. Working with Web Pages  An Introduction to Cascading Style Sheets  Format a Web.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 16 - Dynamic HTML: Data Binding with Tabular Data Control Outline 16.1 Introduction 16.2 Simple.
 2002 Prentice Hall. All rights reserved. Chapter 10: JavaServer Pages Outline 10.1 Introduction 10.2 JavaServer Pages Overview 10.3 A First JavaServer.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 18 - Dynamic HTML: Path Sequencer and Sprite ActiveX Controls Outline 18.1 Introduction 18.2.
JSP Based on
JavaServer Pages (JSP)
MSIS 655 Advanced Business Applications Programming
Java Server Pages.
Chapter 31 - JavaServer Pages (JSP): Bonus for Java™ Developers
COP 4610L: Applications in the Enterprise Spring 2005
COP 4610L: Applications in the Enterprise Spring 2005
Presentation transcript:

 2002 Prentice Hall. All rights reserved. JavaServer Pages

 2002 Prentice Hall. All rights reserved. JavaServer Pages Overview (cont.) Directive –Message to JSP container i.e., program that compiles/executes JSPs –Enable programmers to specify Page settings Content to include from other resources Custom tag libraries used in the JSP

 2002 Prentice Hall. All rights reserved. JavaServer Pages Overview (cont.) Scriptlet –Also called “Scripting Elements” –Enable programmers to insert Java code in JSPs –Performs request processing Interacts with page elements and other components to implement dynamic pages

 2002 Prentice Hall. All rights reserved. JavaServer Pages Overview (cont.) JSPs –Look like standard HTML or XHTML Normally include HTML or XHTML markup –Known as fixed-template data –Used when content is mostly fixed-template data Small amounts of content generated dynamically Servlets –Used when small amount of content is fixed-template data Most content generated dynamically

 2002 Prentice Hall. All rights reserved. A First JavaServer Page Example Simple JSP example –Demonstrates Fixed-template data (XHTML markup) Creating a Java object ( java.util.Date ) Automatic conversion of JSP expression to a String meta element to refresh Web page at specified interval –First invocation of clock.jsp Notice the delay while: –JSP container translates the JSP into a servlet –JSP container compiles the servlet –JSP container executes the servlet Subsequent invocations should not experience the same delay

 2002 Prentice Hall. All rights reserved. Outline Fig Using a JSP expression to insert the date and time in a Web page (Part 1). Line 10 Line <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 " A Simple JSP Example big { font-family: helvetica, arial, sans-serif; 16 font-weight: bold; 17 font-size: 2em; } Simple JSP Example

 2002 Prentice Hall. All rights reserved. Outline Fig Using a JSP expression to insert the date and time in a Web page (Part 2). Program Output

 2002 Prentice Hall. All rights reserved. Implicit Objects (cont.)

 2002 Prentice Hall. All rights reserved. Implicit Objects (cont.)

 2002 Prentice Hall. All rights reserved. Scripting Components JSP scripting components –Scriptlets (delimited by ) –Comments (delimited by ) –Expressions (delimited by ) –Declarations –Escape sequences

 2002 Prentice Hall. All rights reserved. Scripting Components (cont.)

 2002 Prentice Hall. All rights reserved. Outline Fig Scripting a JavaServer Page -- welcome.jsp (Part 1). Lines 17-23, Line 19 Line <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 " Processing "get" requests with data <% // begin scriptlet String name = request.getParameter( "firstName" ); if ( name != null ) { %> Hello, 27 Welcome to JavaServer Pages! <% // continue scriptlet } // end if

 2002 Prentice Hall. All rights reserved. Outline Fig Scripting a JavaServer Page -- welcome.jsp (Part 2). Lines else { %> Type your first name and press Submit <% // continue scriptlet } // end else %>

 2002 Prentice Hall. All rights reserved. Outline Fig Scripting a JavaServer Page -- welcome.jsp (Part 3).

 2002 Prentice Hall. All rights reserved. Action

 2002 Prentice Hall. All rights reserved. Outline Fig JavaServer page guestBook- Login.jsp enables the user to submit a first name, a last name and an address to be placed in the guest book (Part 1). Line 8 Lines <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 " <jsp:useBean id = "guest" scope = "page" 12 class = "com.deitel.advjhtp1.jsp.beans.GuestBean" /> 13 <jsp:useBean id = "guestData" scope = "request" 14 class = "com.deitel.advjhtp1.jsp.beans.GuestDataBean" /> Guest Book Login body { 23 font-family: tahoma, helvetica, arial, sans-serif; 24 } table, tr, td { 27 font-size:.9em; 28 border: 3px groove; 29 padding: 5px; 30 background-color: #dddddd; 31 }

 2002 Prentice Hall. All rights reserved. Outline Fig JavaServer page guestBook- Login.jsp enables the user to submit a first name, a last name and an address to be placed in the guest book (Part 2). Line <% // start scriptlet if ( guest.getFirstName() == null || 41 guest.getLastName() == null || 42 guest.get () == null ) { %> Enter your first name, last name and 48 address to register in our guest book First name Last name

 2002 Prentice Hall. All rights reserved. Outline Fig JavaServer page guestBook- Login.jsp enables the user to submit a first name, a last name and an address to be placed in the guest book (Part 3). Line <input type = "submit" 78 value = "Submit" /> <% // continue scriptlet } // end if 87 else { 88 guestData.addGuest( guest ); %> <% // continue scriptlet } // end else %>

 2002 Prentice Hall. All rights reserved. Outline Fig JavaServer page guestBook- View.jsp displays the contents of the guest book (Part 1). Lines 9-10 Lines <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 " <jsp:useBean id = "guestData" scope = "request" 14 class = "com.deitel.advjhtp1.jsp.beans.GuestDataBean" /> Guest List body { 23 font-family: tahoma, helvetica, arial, sans-serif; 24 } table, tr, td, th { 27 text-align: center; 28 font-size:.9em; 29 border: 3px groove; 30 padding: 5px; 31 background-color: #dddddd; 32 }

 2002 Prentice Hall. All rights reserved. Outline Fig JavaServer page guestBook- View.jsp displays the contents of the guest book (Part 2). Lines Guest List Last name 43 First name <% // start scriptlet List guestList = guestData.getGuestList(); 53 Iterator guestListIterator = guestList.iterator(); 54 GuestBean guest; while ( guestListIterator.hasNext() ) { 57 guest = ( GuestBean ) guestListIterator.next(); %> ">

 2002 Prentice Hall. All rights reserved. Outline Fig JavaServer page guestBook- View.jsp displays the contents of the guest book (Part 3) <% // continue scriptlet } // end while %>