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.

Slides:



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

 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.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
 2007 Pearson Education, Inc. All rights reserved Web Applications: Part 1.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Java Server Pages B.Ramamurthy. Java Server Pages Servlets are pure Java programs. They introduce dynamism into web pages by using programmatic content.
Q: According to Intel, the Pentium conforms to the IEEE standards 754 and 854 for floating point arithmetic. If you fly in aircraft designed using a Pentium,
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
UNIT-V The MVC architecture and Struts Framework.
 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 B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
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.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Component-Based Software Engineering Internet Applications Paul Krause.
 2007 Pearson Education, Inc. All rights reserved JavaServer ™ Faces Web Applications.
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.
 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.
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)
Jordan Anastasiade. All rights reserved.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
J2EE Structure & Definitions Catie Welsh CSE 432
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
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 Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
intro JSP Pertemuan 8 Matakuliah: Web Programming Tahun: 2009.
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.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 41 JavaServer Face.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© 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.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.
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.
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.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Apache Struts Technology A MVC Framework for Java Web Applications.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Introduction to JavaServer Faces and the Woodstock UI Components Presenter Name
Knowledge Byte In this section, you will learn about:
MSIS 655 Advanced Business Applications Programming
JavaServer Faces: The Fundamentals
COP 4610L: Applications in the Enterprise Spring 2005
J2EE Lecture 1:Servlet and JSP
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

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

3 Servlets JSP (JavaServer Pages) JSF (JavaServer Faces) JavaBeans components Netbeans IDE (Integrated Development Environment) for Java-based web applications JSP Example

4 Servlets Java-based components that use the HTTP request-response model of client-server communication Servlet "container" executes servlets and manages their life cycle Servlet APIs – javax.servlet and javax.servlet.http

5 Servlet Container 1.Container Receives an HTTP request from a client 2.Container forwards the request to the corresponding servlet 3.Servlet processes the request and generates XHTML document 4.Container returns the page to the client

6 Servlet Life Cycle Servlet must implement javax.servlet.Servlet interface I.e., it must implements methods called by servlet container when the servlet’s life cycle changes – init() called only the first time there is a request for the servlet – service() called for each request receives the request, processes it and generates a response – destroy() called when servlet is terminated releases all resources

7 JSP Concepts JSP (JavaServer Pages) are web page templates that correspond to servlets JSP allow to –separate presentation from content –create dynamic content predefined components server-side scripting for interaction with the components JSP container converts a JSP page into a servlet –upon the first request for the page –the servlet handles all requests to the JSP JSP use the same request/response mechanism as servlets JSP APIs – javax.servlet.jsp and javax.servlet.jsp.tagext

8 JSP Components Key components –directives –actions –scripting elements –tag libraries –static content JavaBeans and custom tag libraries –encapsulate complex, dynamic functionality –hide code for complex operations e.g., database access –allow web-page designers to add dynamic content to web pages even without knowledge of Java JSTL (JavaServer Pages Standard Tag Library) –provide many common web application tasks

9 JSP Components (cont.) Directives –define page settings and content from other resources –add custom tag libraries –send messages to JSP container Actions –implement functionality of predefined tags –implement client requests –create Java objects needed in JSP Scripting elements –Java code that interacts with JSP components and process requests Tag libraries –let programmers create custom tags –JSTL provide standard, predefined tags Static content –XHTML or XML markup –text: translated to a String object in the corresponding servlet

10 JSF JavaServer Faces –simplify the design of an application’s GUI –separate a web application’s presentation from its business logic JSF custom tag libraries –user interface components –APIs for handling component events The programmer defines –look-and-feel of a JSF page by adding custom tags to a JSP file and setting the tag's attributes –page’s behavior in a separate Java code file

11 Netbeans IDE (Integrated Development Environment) for Java –from Sun, but free –similar, but different from Eclipse –plugins for web applications development Netbeans includes –visual designer for dropping components onto a page –text editor editing its.jsp file manually Netbeans web applications –JSPs built with JSF.jsp file contains also page’s GUI elements –a page bean (i.e. a JavaBean class) for each JSP page

12 Page Beans Page bean defines –properties of page elements getProperty() and setProperty() methods –event handlers –methods page life-cycle methods supporting code Netbeans web application is composed of –page beans – RequestBean – SessionBean – ApplicationBean

13 Web Application Beans RequestBean –request scope –exists only during an HTTP request SessionBean –session scope –exists while the user is browsing or until the session times out –unique for each user ApplicationBean –application scope –shared by all instances of the application regardless of the number of open sessions –exists while the application is deployed –application-wide data storage and processing

14 Example copyright 2007 Pearson Education

15 Example's JSP <jsp:root version = "1.2" xmlns:f = " xmlns:h = " xmlns:jsp = " xmlns:webuijsf = " <webuijsf:staticText binding = "#{Time.timeHeader}" id = "timeHeader" style = "font-size: 18px; left: 24px; top: 24px; position: absolute" text = "Current time on the web server:" /> <webuijsf:staticText binding = "#{Time.clockText}" id = "clockText" style = "background-color: black; color: yellow; font-size: 18px; left: 24px; top: 48px; position: absolute" />

16 Example's Java Code // Textbook Fig. 26.3: Time.java copyright 2007 Pearson Education // Page bean file that sets clockText to the time on the Web server. package webtime; import com.sun.rave.web.ui.appbase.AbstractPageBean; import com.sun.webui.jsf.component.*; import java.text.DateFormat; import java.util.Date; import javax.faces.FacesException; public class Time extends AbstractPageBean { private Page page = new Page (); private Html html = new Html (); private Head head = new Head (); private Link link = new Link (); private Body body = new Body (); private Form form = new Form (); private StaticText timeHeader = new StaticText (); private StaticText clockText = new StaticText (); private Meta meta = new Meta (); public Page getPage () {return page;} public void setPage (Page page) {this.page = page;} public Html getHtml () {return html;} public void setHtml (Html html) {this.html = html;} public Head getHead () {return head;} public void setHead (Head head) {this.head = head;}

17 Example's Java Code (cont.) public Link getLink () {return link;} public void setLink (Link link) {this.link = link;} public Body getBody () {return body;} public void setBody (Body body) {this.body = body;} public Form getForm () {return form;} public void setForm (Form form) {this.form = form;} public StaticText getTimeHeader () {return timeHeader;} public void setTimeHeader (StaticText text) {this.timeHeader = text;} public StaticText getClockText () {return clockText;} public void setClockText (StaticText text) {this.clockText = text;} public Meta getMeta () {return meta;} public void setMeta (Meta meta) {this.meta = meta;} /* Constructs new Time */ public Time () {} /* Initializes page */ public void init () {super.init ();}

18 Example's Java Code (cont.) /* Called on postback */ public void preprocess () {} /* Sets the clock. Called before page is rendered */ public void prerender () { DateFormat formatter = DateFormat.getTimeInstance (DateFormat.LONG); clockText.setValue (formatter.format (new Date ())); } /* Called after page is rendered */ public void destroy () {} /* Returns a request bean */ protected RequestBean1 getRequestBean1 () { return (RequestBean1) getBean ("RequestBean1"); } /* Returns a session bean */ protected SessionBean1 getSessionBean1 () { return (SessionBean1) getBean ("SessionBean1"); } /* Returns an application bean */ protected ApplicationBean1 getApplicationBean1 () { return (ApplicationBean1) getBean ("ApplicationBean1"); }