J2EE Web Fundamentals Lesson 7 JSP

Preview:

DESCRIPTION

J2EE Web Fundamentals Lesson 7 JSP. Instructor: Dr. Segun Adekile. Outline. Objectives Course Text Book Basham, Bryan; Sierra, Kathy; Bates, Bert (2012-10-30). Head First Servlets and JSP (Kindle Location 1349). O'Reilly Media. Kindle Edition. Using JSP: Being a JSP. Objectives. Agenda. - PowerPoint PPT Presentation

Citation preview

J2EE Web FundamentalsLesson 7

JSP

Instructor: Dr. Segun Adekile

Outline

• Objectives• Course Text Book– Basham, Bryan; Sierra, Kathy; Bates, Bert (2012-

10-30). Head First Servlets and JSP (Kindle Location 1349). O'Reilly Media. Kindle Edition.

• Using JSP:– Being a JSP

Objectives

Agenda• Introduction

– Why JSPs?– What is a JSP?

• Page Directive• JSP Element: Expressions• JSP Element: Declarations• Implicit Objects• Comments• Standard Actions• Expression Language• JSTL• Custom Tag Development

Why JSPs?

What is a JSP?

• A JSP is a servlet

What is a JSP?

• In the end, a JSP is just a servlet• Your JSP eventually becomes a full-fledged servlet running in your web

app. • It’s a lot like any other servlet, except that the servlet class is written for

you — by the Container. • The Container takes what you’ve written in your JSP, translates it into a

servlet class source (. java) file, then compiles that into a Java servlet class. • After that, it’s just servlets all the way down, and the servlet runs in

exactly the same way it would if you’d written and compiled the code yourself.

• In other words, the Container loads the servlet class, instantiates and initializes it, makes a separate thread for each request, and calls the servlet’s service() method.

A Simple JSP

Page Directive

Expressions

Declarations

Declarations

Declarations

Declarations

Generated Servlet

Generated Servlet

Implicit Objects

Comments

API for JSP Servlet

Lifecycle of a JSP

Lifecycle of a JSP

Initializing JSP

Attributes in a JSP

Three Directives

Page Directive attributes

Page Directive attributes

Scriptlets considered harmful?

Expression Language

Recap

Recommended