DOC PREVIEW
LETU COSC 2103 - JavaServer Pages

This preview shows page 1-2-3-4-5-36-37-38-39-40-73-74-75-76-77 out of 77 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 25: JavaServer Pages25.1 Introduction25.2 JavaServer Pages Overview25.2 JavaServer Pages Overview (cont.)Slide 5Slide 6Slide 7Slide 8Slide 9Slide 1025.3 A First JavaServer Page ExampleCock.jsp Line 10 Meta element refershes the Web page every 60 seconds.Cock.jsp Line 30 Creates Date objectClock.jsp25.4 Implicit ObjectsPowerPoint Presentation25.5 Scripting25.5.1 Scripting Components25.5.1 Scripting Components (cont.)25.5.2 Scripting Examplewelcome.jsp Lines 17-23 Line 19welcome.jsp Line 26 Lines 30-35 and 45-49welcome.jsp25.6 Standard ActionsSlide 2525.6.1 <jsp:include> Action25.6.1 <jsp:include> Action (cont.)banner.htmltoc.htmlSlide 30clock2.jsp Lines 14-20include.jspinclude.jsp Lines 38-39 Use JSP action to include banner.html. Line 48 Use JSP action to include toc.html.include.jsp Lines 55-56 Use JSP action to include clock2.jsp.Slide 3525.6.2 <jsp:forward> Actionforward1.jsp Lines 22-25forward1.jspforward2.jsp Lines 23-24forward2.jsp Line 3125.6.3 <jsp:useBean> Action25.6.3 <jsp:useBean> Action (cont.)Rotator.javaRotator.java Lines 25-28 Lines 31-34 Lines 38-41adrotator.jsp Lines 7-8 Line 22adrotator.jsp Lines 29-33Slide 4725.7 Directives25.7 Directives (cont.)25.7.1 page Directive25.7.1 page Directive (cont.)Slide 52Slide 5325.7.2 include DirectiveincludeDirective.jspincludeDirective.jsp Line 38 Line 47includeDirective.jsp Line 5425.8 Case Study: Guest BookGuestBean.java Line 6GuestBean.javaGuestDataBean.java Line 18 Line 21 Lines 22-23GuestDataBean.java Lines 31-51GuestDataBean.java Lines 54-59guestBook-Login.jsp Line 8 Lines 11-14guestBook-Login.jsp Line 36guestBook-Login.jspguestBook-Login.jsp Line 93guestBook-View.jsp Lines 9-10 Lines 13-14guestBook-View.jspguestBook-View.jsp Lines 50-68guestBook-View.jspguestBookError-View.jsp Line 8guestBookError-View.jsp Lines 31 and 37guestBookError-View.jsp25.8 Case Study: Guest Book (Cont.)Slide 7625.9 Internet and World Wide Web Resources 2003 Prentice Hall, Inc. All rights reserved.Chapter 25: JavaServer PagesOutline25.1 Introduction25.2 JavaServer Pages Overview25.3 First JavaServer Page Example25.4 Implicit Objects25.5 Scripting25.5.1 Scripting Components25.5.2 Scripting Example25.6 Standard Actions25.6.1 <jsp:include> Action25.6.2 <jsp:forward> Action25.6.3 <jsp:useBean> Action25.7 Directives25.7.1 page Directive25.7.2 include Directive25.8 Custom Tag Libraries25.9 Internet and World Wide Web Resources 2003 Prentice Hall, Inc. All rights reserved.25.1 Introduction•JavaServer Pages–Extension of Servlet technology•Web content delivery•Reuse existing Java components–Without programming Java•Create custom tags–Encapsulate complex functionality•Classes and interfaces specific to JSP–Package javax.servlet.jsp–Package javax.servlet.jsp.tagext 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview•Key components–Directives–Actions–Scriptlets–Tag libraries 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•Directive–Message to JSP container•i.e., program that compiles/executes JSPs–Enable programmers to specify•Page settings•Content to include from other resources•Custom tag libraries used in the JSP 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•Action–Predefined JSP tags that encapsulate functionality–Often performed based on information from client request–Can be used to create Java objects for use in scriptlets 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•Scriptlet–Also called “Scripting Elements”–Enable programmers to insert Java code in JSPs–Performs request processing•Interacts with page elements and other components to implement dynamic pages 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•Custom Tag Library–JSP’s tag extension mechanism–Enables programmers to define new tags•Tags encapsulate complex functionality–Tags can manipulate JSP content 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•JSPs–Look like standard HTML or XHTML •Normally include HTML or XHTML markup–Known as fixed-template data–Used when content is mostly fixed-template data•Small amounts of content generated dynamically•Servlets–Used when small amount of content is fixed-template data •Most content generated dynamically 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•Some servlets do not produce content–Invoke other servlets and JSPs•JSPs execute as part of a Web server–JSP container•JSP first request–JSP container translates a JSP into a servlet•Handle the current and future requests•Code that represents the JSP–Placed in servlet’s _jspService method 2003 Prentice Hall, Inc. All rights reserved.25.2 JavaServer Pages Overview (cont.)•JSP errors –Translation-time errors •Occur when JSPs are translated into servlets –Request-time errors•Occur during request processing•Methods jspInit and jspDestroy–Container invokes when initializing and terminating a JSP•Methods are defined in JSP declarations–Part of the JSP scripting mechanism 2003 Prentice Hall, Inc. All rights reserved.25.3 A First JavaServer Page Example•Simple JSP example (Fig. 25.1)–Demonstrates •Fixed-template data (XHTML markup)•Creating a Java object (java.util.Date)•Automatic conversion of JSP expression to a String•meta element to refresh Web page at specified interval–First invocation of clock.jsp•Notice the delay while:–JSP container translates the JSP into a servlet–JSP container compiles the servlet–JSP container executes the servlet•Subsequent invocations should not experience the same delay 2003 Prentice Hall, Inc.All rights reserved.OutlineCock.jspLine 10Meta element refershes the Web page every 60 seconds.1 <?xml version = "1.0"?>2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">4 5 <!-- Fig. 25.1: clock.jsp -->6 7 <html xmlns = "http://www.w3.org/1999/xhtml">8 9 <head>10 <meta http-equiv = "refresh" content = "60" />11 12 <title>A Simple JSP Example</title>13 14 <style type = "text/css">15 .big { font-family: helvetica, arial, sans-serif;16 font-weight:


View Full Document

LETU COSC 2103 - JavaServer Pages

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download JavaServer Pages
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view JavaServer Pages and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view JavaServer Pages 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?