Java Server Pages Jeffrey Jongko. Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet.

Slides:



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

Java Server Pages (JSP)
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
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.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
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.
JSP Java Server Pages Reference:
DT228/3 Web Development JSP: Directives and Scripting elements.
Java Server Pages B.Ramamurthy. Java Server Pages Servlets are pure Java programs. They introduce dynamism into web pages by using programmatic content.
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,
Comp2513 Java Server Pages Daniel L. Silver, Ph.D.
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.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
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.
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
Netbeans – jsp.zip Introduction to JSP Netbeans – jsp.zip.
Introduction to Java Server Pages (JSPs) Robert Thornton.
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.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
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.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
Web Server Programming 3. Server side includes. HTML+ (‘hole’) technologies Uses ‘HTML+”, HTML (or XML) extended with code. Very many different varieties.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
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 © 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.
CSC 2720 Building Web Applications JavaServer Pages (JSP) JSP Directives and Action Elements.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
JSP. Types of JSP Scripting Elements Expressions of the form, which are evaluated and inserted into the servlet's output. Scriptlets of the form, which.
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.
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.
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.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
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,
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.
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.
JSP Directive and Objects. JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action.
JSP Java Server Pages. Hello, !
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
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.
Java Server Pages.
MSIS 655 Advanced Business Applications Programming
Java Server Pages.
JSP Directives 1-Jan-19.
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:

Java Server Pages Jeffrey Jongko

Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet technology Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet technology Java Servlets was Sun’s first answer for developing web-based applications use the Java programming language. Java Servlets was Sun’s first answer for developing web-based applications use the Java programming language.

Introduction Java Servlet technology suffered similar maintenance problems that many traditional web-technologies like CGI had (presentation and logic are combined) Java Servlet technology suffered similar maintenance problems that many traditional web-technologies like CGI had (presentation and logic are combined) JSP is designed to facilitate development of dynamic web sites by more easily dissociating presentation from application logic JSP is designed to facilitate development of dynamic web sites by more easily dissociating presentation from application logic –allowing page developers to develop page presentation without interfering with application logic development

JSP Architecture The purpose of JSP is to provide a declarative, presentation-centric method of developing servlets. The purpose of JSP is to provide a declarative, presentation-centric method of developing servlets. JSP specification is defined as a standard extension on top the Servlet API. JSP specification is defined as a standard extension on top the Servlet API. Consequently, it should not be too surprisingly that under the covers, servlets and JSP pages have a lot in common. Consequently, it should not be too surprisingly that under the covers, servlets and JSP pages have a lot in common.

JSP Architecture Typically, JSP pages exist as simple text files and are subject to a translation phase and a request processing phase. Typically, JSP pages exist as simple text files and are subject to a translation phase and a request processing phase. The translation phase is carried out only once, unless the JSP page changes, in which case it is repeated. The translation phase is carried out only once, unless the JSP page changes, in which case it is repeated. –The JSP page is transformed into a servlet which subsequently processes all future requests to the page

JSP Architecture

Sample JSP file <% String hello = "Hello World"; %> The following JSP file is saved to a file HelloWorld.jsp The following JSP file is saved to a file HelloWorld.jsp It looks like regular HTML will special regions delimited with special markers like “ ” which represent JSP features It looks like regular HTML will special regions delimited with special markers like “ ” which represent JSP features

JSP Syntax core elements There are four basic core elements in JSP There are four basic core elements in JSP –comments –declarations –expressions –scriptlets

JSP Comments There are 2 types of JSP comments There are 2 types of JSP comments –HTML comment –Hidden comment HTML Comment Syntax HTML Comment Syntax ] --> ] --> Hidden Comment Syntax Hidden Comment Syntax A JSP HTML comment is a comment that is sent to the client (appears on the page data) A JSP HTML comment is a comment that is sent to the client (appears on the page data) JSP expressions (seen later) can be included inside an HTML comment JSP expressions (seen later) can be included inside an HTML comment

Sample JSP Comments <!-- Loaded on --> <% String hello = "Hello World"; %> </body></html> DATA RECEIVED BY CLIENT: Hello World

JSP Declarations JSP Declarations are used to define variables and methods that are visible to the whole page JSP Declarations are used to define variables and methods that are visible to the whole page –variables are translated into an instance variable in the compiled servlet JSP Declaration Syntax JSP Declaration Syntax Variables declared in this way are not thread- safe. The JSP page has to be declared as single-threaded if thread safety is needed for these variables. Variables declared in this way are not thread- safe. The JSP page has to be declared as single-threaded if thread safety is needed for these variables.

Sample JSP Declaration <%! int counter = 0; boolean isSameString(String a, String b) { return a.equals(b); } %> bjlee and hjk is <%= (isSameString(“bjlee”,”hjk”)) ? ”” : ”not” %> same string OUTPUT ON CLIENT: bjlee and hjk is not same string

JSP Expressions Scripting language expression that is evaluated and converted into a String for insertion into the output page Scripting language expression that is evaluated and converted into a String for insertion into the output page JSP Expression Syntax JSP Expression Syntax

Sample JSP Expressions <!-- Loaded on --> <% String hello = "Hello World"; %> </body></html> DATA RECEIVED BY CLIENT: Hello World

JSP Scriptlets Scripting language code fragment that is run within the service() method of the compiled servlet Scripting language code fragment that is run within the service() method of the compiled servlet –variables declared within a scriptlet are local unlike those declared by JSP Declarations JSP Scriptlet Syntax JSP Scriptlet Syntax

Sample JSP Scriptlet <% String name = “Byung Joon Lee”; StringTokenizer st= new StringTokenizer(name, “ “); while ( st.hasMoreTokens() ) { %> <% } %> OUTPUT ON CLIENT: Byung Joon Lee

Directive Directive directive defines attributes that apply to a whole JSP page directive defines attributes that apply to a whole JSP page Example of some attributes: [ language=“java”] [ extends=“package.class”] [ import=“{package.class | package.*},...”] [ session=“true|false”] [ isThreadSafe=“true|false”] [ info=“text”] [ errorPage=“relativeURL”] [ isErrorPage=“true|false”]

Implicit Objects Data is passed to JSP pages from the outside via HTTP POST or GET Data is passed to JSP pages from the outside via HTTP POST or GET This data is accessed via an implicit object This data is accessed via an implicit object –the name of this object is called request of type –the name of this object is called request of type javax.servlet.ServletRequest – –implicit objects are accessed via the scriptlets Other implicit objects exist such as Other implicit objects exist such as –response of type –response of type javax.servlet.ServletResponse – –pageContext – –session – –application

Other JSP features Ability to access JavaBean components using JSP tags, e.g. Ability to access JavaBean components using JSP tags, e.g. – – This allows access to JavaBean objects without the use of scriptlets/Java code This allows access to JavaBean objects without the use of scriptlets/Java code

Other JSP features Ability to extend the usable JSP tags using a custom tag library Ability to extend the usable JSP tags using a custom tag library –this is used to reduce the number of scriptlets on the page by encapsulating their logic behind tags. Both these features reduce the need for people with actual Java language experience which is needed for coding scriptlets Both these features reduce the need for people with actual Java language experience which is needed for coding scriptlets –allows for the development of presentation (JSP page) and the actual business logic (JavaBeans) to developed separately

Sites Some sites that use Java Server Pages Some sites that use Java Server Pages – –

References onlineTraining/JSPIntro/ onlineTraining/JSPIntro/ onlineTraining/JSPIntro/ onlineTraining/JSPIntro/