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.

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.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Introduction to Servlets Based on: Hall, Brown, Core Servlets and JavaServer Pages.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Servlets Stoney Jackson
CSE 190: Internet E-Commerce Lecture 7. HTML Templates Designed to separate server side logic from HTML presentation Key features –Escapes from HTML into.
Java Server Pages by Jon Pearce. JSP Documents JSP docs are XHTML Documents containing: –Fixed-Template Data: FTD HTML Components XML markup –JSP Components:
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.
Generate Dynamic Content On Cache Server Master’s Project Proposal by Aparna Yeddula.
JSP Java Server Pages Reference:
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
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,
Introduction to Servlet & 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
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
Java Servlets and JSP.
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.
Servlet and JSP Programming: An Introduction Spiros Papadimitriou
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
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.
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.
Java Servlets and Java Server Pages Carol Wolf Computer Science.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
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.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
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 SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
1 JSP with Custom Tags Blake Adams Introduction Advanced Java Server Pages – Custom Tags Keyterms: - Tag Library Descriptor(TLD) - Tag Libraries.
COMP 321 Week 11. Overview Lab 8-1 Solution Tag Files Custom Tags Web Application Deployment.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
Chapter 2 Web app architecture. High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what.
Java Server Pages (JSP)
S ERVLETS Hits Counter 21-Nov-15. S ERVLETS - H ITS C OUNTER Many times you would be interested in knowing total number of hits on a particular page of.
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 ►
Chapter 11 Invoking Java Code with JSP Scripting Elements.
Java Servlets and Java Server Pages Norman White Stern School of Business.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
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.
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java Servlets and Java Server Pages
INVOKING JAVA CODE WITH JSP SCRIPTING ELEMENTS. Creating Template Text A large percentage of your JSP document consists of static text (usually HTML),
Introduction To HTML Dr. Magdi AMER. HTML elements.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
 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 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.
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
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.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
CS3220 Web and Internet Programming Introduction to Java Servlets
Servlets Hits Counter 20-Jul-18.
Java Server Pages.
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Presentation transcript:

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 and maintain dynamic web pages and dynamic XML documents

Servlet vs. JSP Import java.io.*; import javax.servlet.*; import javax.servlet.http.*; publc class HtmlPage extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType(“text/html”); PrintWriter out = response.getWriter(): String name = req.getParameter(“name”); out.Println(“ ”); out.Println(“ First Servlet ”); out.Println(“ ”); out.Println(“ Hello “ + name + “ ”); out.Println(“ ”); out.Println(“ ”); } } Servlet Example

Servlet vs. JSP (cont) First Servlet Hello JSP Example Presentation centric Presentation is separated from content Easier to code Better organization of Web application

Recommendation Use JSP –If presentation changes frequently –Presentation is complex Use Servlets –Validation, simple business logic –Simple/small presentation

Anatomy of a JSP Page Template (static HTML or XML) JSP Elements Tag libraries Element TypeJSP SyntaxDescription Directives Controls to define translation into Java code Scripting Embed Java code in HTML Actions JSP-specific tag for Java Beans

HTML (XML) Template First Servlet Hello

JSP Elements Directive Elements First Servlet Hello World

JSP Elements Scripting Elements First Servlet Hello World The total amount is Declarations Scriplet Expression

JSP Elements Action Elements First Servlet Include resource Forward page Set value of class variable in Java Bean

Accessing Servlet Variables config request response session out pageContext application page

JSP Elements Servlet Variables First Servlet Hello World Date: The total amount is

Simplify JSP Development Use Java Beans Use Tag Libraries

Model/View/Controller JavaBean Request object JSP/Servlets in the Enterprise Servlet JSP page Data base Web Server Model One Architecture Output doGet/ doPost Input >

Using Java Beans in JSP Model 1 JSP Page 2 …..... lastname = firstname = lastname = firstname = …. Getting values from a java bean Get Java Bean Reference Java Bean class variables

Using Java Beans in JSP Model 1 JSP Page 1 …. …. ”/> …. Creating a java bean and setting values in the java bean Create Java Bean Forward request to next JSP page

Using Java Beans in JSP Model 1 JSP Page 2 …..... Last name = first name = Username = Password = …. Getting values from a java bean Get Java Bean Reference Java Bean class variables

Tag Libraries Create custom XML tags that you can imbed in JSP pages –Custom commands (i.e., macros) –Java tag handler class defined for each custom tag –XML tag in JSP  Java method called for tag

Tag Types XML format –Tag without a body –Tag without a body but with an attribute –Tag with body and an attribute Title of Table

Tag Handler Class import java.io.*; import java.servlet.jsp.*; import java.servlet.jsp.tagext.*; public class DeptHeader extends TagSupport { public int doStartTag() { try { JspWriter out = pageContext.getOut(); out.println(“ Information Systems Dept. ”); out.println(“ Brigham Young University-Idaho ”); } catch (IOException ioex) { …. } return (SKIP_BODY); } public int doEndTag() { return(EVAL_PAGE); } } Inherit TagSupport Invoked at starting tag Invoked at ending tag

Tag Library Descriptor 1.0 > 1.2 homeDirectBank deptHeader homedirectbank.DeptHeader EMPTY Inserts IS department header

Using Tag in JSP Page homeDirectBank deptHeader com.taglib.homedirectbank.DeptHeader EMPTY Inserts IS department header Tag Library Descriptor (homeDrectBank) Test Servlet ….. ….. } JSP Page import java.io.*; import java.servlet.jsp.*; import java.servlet.jsp.tagext.*; public class DepHeader extends TagSupport { public int doStartTag() { try { JspWriter out = pageContext.getOut(); out.println(“ Information Systems Dept. ”); out.println(“ Brigham Young University-Idaho ”); } catch (IOException ioex) { …. } return (SKIP_BODY); } public int doEndTag() { return(EVAL_PAGE); } } Tag Handler Class maps uses