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,

Slides:



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

Java Server Pages (JSP)
Apache Struts Technology
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
 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.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
CS320 Web and Internet Programming JSP Scripting Elements and Page Directives Chengyu Sun California State University, Los Angeles.
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,
1 CS6320 – JSP L. Grewe 2 Java Server Pages Servlets require you to write out entire page delivered with print statements Servlets require you to write.
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.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
1 Chapter 2 The Web Tier  Web Applications and Web ContainersWeb Applications and Web Containers  Dynamic Content CreationDynamic Content Creation 
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.
Introduction to JSP Based on: Marty Hall, Larry Brown, Core Servlets and JavaServer Pages.
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)
Jordan Anastasiade. All rights reserved.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
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.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
SE-2840 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.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Java Server Pages (JSP)
Java Server Pages An introduction to JSP. Containers and Components Several clients – one system.
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.
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.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
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.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
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,
JSP JavaServer Pages. What is JSP? Java based technology that simplifies the development of dynamic web sites JSP pages are HTML pages with embedded code.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
Apache Struts Technology A MVC Framework for Java Web Applications.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
JSP Based on
JSP (Java Server Page) JSP is server side technology which is used to create dynamic web pages just like Servlet technology. This is mainly used for implementing.
COMP9321 Web Application Engineering Semester 2, 2017
Pre-assessment Questions
Introduction to JSP Java Server Pages
Knowledge Byte In this section, you will learn about:
Chengyu Sun California State University, Los Angeles
JSP Directives 1-Jan-19.
COP 4610L: Applications in the Enterprise Spring 2005
JSP implicit objects & directive elements
Introduction to JSP Dept. of B.Voc Software Development and System Administration St. Joseph’s College(Autonomous) Trichy-02 By Dr. J. Ronald Martin Introduction.
Presentation transcript:

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, What is JSP ? Elements of a JSP document JavaBeans and JSP TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary Internet Applications, Lecture 4

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Agenda What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling Custom Tags, JSP Standard Tag Library JSP and Java Servlets JSP v2.0 – new features Summary What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content What is JSP ? „The JavaServer Pages technology provides the means for textual specification of the creation of a dynamic response to a request” (JSP Spec. v1.2) What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content What is JSP ? JSP is a textual specification of the creation of a dynamic response to a request (JSP Spec. v1.2) /** */ public class SomeServlet extends HttpServlet { /** */ protected void doGet(...) { //... out.println(„ Title ”); out.println(„ Today is:”); out.println(new java.util.Date().toString()); out.println(„ ”); out.close(); } /** */ public class SomeServlet extends HttpServlet { /** */ protected void doGet(...) { //... out.println(„ Title ”); out.println(„ Today is:”); out.println(new java.util.Date().toString()); out.println(„ ”); out.close(); } What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content What is JSP ? Title ; Today is: Title ; Today is: JSP is a textual specification of the creation of a dynamic response to a request (JSP Spec. v1.2) What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Elements of a JSP document import=„java.util.*" contentType="text/html" session="true" %> Title Today is: <% date = new Date().toString(); %> import=„java.util.*" contentType="text/html" session="true" %> Title Today is: <% date = new Date().toString(); %> Directives page – JSP document properties Static content written verbatim to the output document Declarations of global variables and methods Java code ("scriptlets") executed on request time Expressions evaluated on request time Actions executed on request time Comment not copied to the output document What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Implicit Objects In every JSP document a number of implicit objects can be accessed: application (javax.servlet.ServletContext) config (javax.servlet.ServletConfig) out (javax.servlet.jsp.JspWriter) request (javax.servlet.ServletRequest) response (java.servlet.ServletResponse) session (javax.servlet.http.HttpSession) exception (java.lang.Throwable) What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JavaBeans in JSP (1) package org.stachoodev.examples.*; /** */ public class Login { /** */ private String userId, password; /** */ public void setUserId(String userId) { this.userId = userId; } /** */ public void setPassword(String password) { this.password = password; } /** */ public boolean isLoginCorrect() { return userId.equals(password); } package org.stachoodev.examples.*; /** */ public class Login { /** */ private String userId, password; /** */ public void setUserId(String userId) { this.userId = userId; } /** */ public void setPassword(String password) { this.password = password; } /** */ public boolean isLoginCorrect() { return userId.equals(password); } What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JavaBeans in JSP (2) import="org.stachoodev.examples.*" contentType="text/html" %> Login <% Login login = new Login(); login.setUserId(request.getParameter("userId”)); login.setPassword(request.getParameter("password”)); %> Login successful. Login failed. import="org.stachoodev.examples.*" contentType="text/html" %> Login <% Login login = new Login(); login.setUserId(request.getParameter("userId”)); login.setPassword(request.getParameter("password”)); %> Login successful. Login failed. What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JavaBeans in JSP (3) import="org.stachoodev.examples.*" contentType="text/html" %> Login <% login.setUserId(request.getParameter("userId")); login.setPassword(request.getParameter("password")); %> Login successful. Login failed. import="org.stachoodev.examples.*" contentType="text/html" %> Login <% login.setUserId(request.getParameter("userId")); login.setPassword(request.getParameter("password")); %> Login successful. Login failed. What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JavaBean instance scope The scope parameter of the jsp:useBean action determines the "visibility" of a JavaBean instance: page – the bean is visible only within the JSP page containing its declaration request – the bean is visible in any JSP page processing the same request session – the instance is accessible across the current user session application – any JSP page can access the JavaBean instance What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JavaBeans in JSP (4) import="org.stachoodev.examples.*" contentType="text/html" %> <jsp:setProperty name="login" property="userId" value=" " /> <jsp:setProperty name="login" property="passowrd" value=" " /> Login Login successful. Login failed. import="org.stachoodev.examples.*" contentType="text/html" %> <jsp:setProperty name="login" property="userId" value=" " /> <jsp:setProperty name="login" property="passowrd" value=" " /> Login Login successful. Login failed. What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JavaBeans in JSP (5) import="org.stachoodev.examples.*" contentType="text/html" %> Login Login successful. Login failed. import="org.stachoodev.examples.*" contentType="text/html" %> Login Login successful. Login failed. What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Exception handling What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary contentType="text/html" errorPage="error.jsp" %> Test page <% ((String)null).length(); %> contentType="text/html" errorPage="error.jsp" %> Test page <% ((String)null).length(); %> contentType="text/html" isErrorPage="true" %> Error An error has occurred: contentType="text/html" isErrorPage="true" %> Error An error has occurred: error.jsp

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Including and forwarding import="org.stachoodev.examples.*" contentType="text/html" %> import="org.stachoodev.examples.*" contentType="text/html" %> What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Custom Tags (1) import="org.stachoodev.examples.*" contentType="text/html" %> prefix="util" uri="util.tld" %> " /> import="org.stachoodev.examples.*" contentType="text/html" %> prefix="util" uri="util.tld" %> " /> What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Custom Tags (2) To implement a Custom JSP Tag: Create the tag handler class (doStartTag(), doEndTag(),...) Create the class describing the variables accesible within the Custom Tag (optional) Create the Tag Library Descriptor (TLD file) What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JSP Standard Tag Library A standardized library of JSP Custom Tags: conditions, loops, enumerations URL transformations content localization formatting of numbers and dates SQL queries XML processing XSLT transformations validation of JSP documents What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JSP and Java Servlets Title ; Today is: Title ; Today is: User Agent (IE, Netscape,...) JSP Container generation + compilation execution HTTP request Java Servlet What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JSP test <% date = new Date().toString(); %> Today is: JSP test <% date = new Date().toString(); %> Today is: JSP and Java Servlets package org.apache.jsp; import java.util.*; import javax.servlet.*; //... public class test$jsp extends HttpJspBase { // begin [file="/test.jsp";from=(8,9);to=(8,23)] String date; // end public void _jspService(...) { //... session = pageContext.getSession(); // HTML [file="/test.jsp";from=(2,36);to=(8,6)] out.write("\r\n\r\n \r\n JSP..."); // end // begin [file="/test.jsp";from=(9,8);to=(11,6)] date = new Date().toString(); // end // begin [file="/test.jsp";from=(14,9);to=(14,15)] out.print( date ); // end } package org.apache.jsp; import java.util.*; import javax.servlet.*; //... public class test$jsp extends HttpJspBase { // begin [file="/test.jsp";from=(8,9);to=(8,23)] String date; // end public void _jspService(...) { //... session = pageContext.getSession(); // HTML [file="/test.jsp";from=(2,36);to=(8,6)] out.write("\r\n\r\n \r\n JSP..."); // end // begin [file="/test.jsp";from=(9,8);to=(11,6)] date = new Date().toString(); // end // begin [file="/test.jsp";from=(14,9);to=(14,15)] out.print( date ); // end } What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content JSP Specification v2.0 A lot of changes and improvements: Expression Language (EL) – scriptless JSP Tag Files based on Servlet Specification v2.4 requires Java 2 Platform v1.4 to be implemented in Tomcat 5.0 What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Summary JSP vs. Java Servlets: better, though still imperfect, code- content separation Tag Libraries - extensibility and component reuse faster development (less typing ;) development tools available What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Summary JavaServer Pages Home JSP Standard Templates Library Tomcat – Reference Implementation What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary

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, Thank you for your attention What is JSP ? Elements of a JSP document JavaBeans and JSP Exception handling TagLibs, JSTL JSP and Java Servlets JSP v2.0 Summary