Trabalhando com JavaServer Pages (JSP)

Similar documents
Trabalhando com JavaServer Pages (JSP)

JavaServer Pages (JSP): Bonus for Java Developers (on CD)

Unit 5 JSP (Java Server Pages)

JavaServer Pages. Juan Cruz Kevin Hessels Ian Moon

Unit 4 Java Server Pages

directive attribute1= value1 attribute2= value2... attributen= valuen %>

COMP9321 Web Application Engineering

A Gentle Introduction to Java Server Pages

Basic Principles of JSPs

Enterprise Computing with Java MCA-305 UNIT II. Learning Objectives. JSP Basics. 9/17/2013MCA-305, Enterprise Computing in Java

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP:

JavaServer Pages (JSP)

Java Server Pages. Copyright , Xiaoping Jia. 7-01/54

PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II

COMP9321 Web Application Engineering

Java Server Pages, JSP

JSP MOCK TEST JSP MOCK TEST III

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

COMP9321 Web Application Engineering

Java Server Page (JSP)

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, JSPs 1

JavaServer Pages. What is JavaServer Pages?

JSP - ACTIONS. There is only one syntax for the Action element, as it conforms to the XML standard:

JSP. Basic Elements. For a Tutorial, see:

Introdução a Servlets

Java Server Pages JSP

01KPS BF Progettazione di applicazioni web

Java Server Pages. JSP Part II

1. Introduction. 2. Life Cycle Why JSP is preferred over Servlets? 2.1. Translation. Java Server Pages (JSP) THETOPPERSWAY.

CE212 Web Application Programming Part 3

112. Introduction to JSP

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

Definitions and some examples JSP. Java Server Pages. By Hamid Mosavi-Porasl

112-WL. Introduction to JSP with WebLogic

About the Authors. Who Should Read This Book. How This Book Is Organized

Fast Track to Java EE 5 with Servlets, JSP & JDBC

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

UNIT -5. Java Server Page

CHAPTER 1. Core Syntax Reference

Introduction to Java Server Pages. Enabling Technologies - Plug-ins Scripted Pages

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Exercise. (1) Which of the following can not be used as the scope when using a JavaBean with JSP? a. application b. session c. request d.

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

20/08/56. Java Technology, Faculty of Computer Engineering, KMITL 1

Unit 4. CRM - Web Marketing 4-1

Advanced Java Programming

More JSP. Advanced Topics in Java. Khalid Azim Mughal Version date: ATIJ More JSP 1/42

Java E-Commerce Martin Cooke,

SNS COLLEGE OF ENGINEERING, Coimbatore

Html basics Course Outline

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0

GUJARAT TECHNOLOGICAL UNIVERSITY

JSP MOCK TEST JSP MOCK TEST IV

Fast Track to Java EE

Java Server Pages(JSP) Unit VI

6- JSP pages. Juan M. Gimeno, Josep M. Ribó. January, 2008

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Advantage of JSP over Servlet

Introduction to WEB PROGRAMMING

Cascading Style Sheets Level 2

A JavaBean is a class file that stores Java code for a JSP

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Ch04 JavaServer Pages (JSP)

Introduction to JSP and Servlets Training 5-days

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

XML and XSLT. XML and XSLT 10 February

SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY- VIRUDHUNAGAR

By completing this practical, the students will learn how to accomplish the following tasks:

Module 3 Web Component

Java 2 Platform, Enterprise Edition: Platform and Component Specifications

JSP Scripting Elements

CSS: Cascading Style Sheets

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Adv. Web Technology 3) Java Server Pages

JSP source code runs on the web server via JSP Servlet Engine. JSP files are HTML files with special Tags

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

SESM Components and Techniques

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

Chapter 2 How to structure a web application with the MVC pattern

Web Applications: Part 1

A Balanced Introduction to Computer Science, 3/E

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

CSS: The Basics CISC 282 September 20, 2014

Introduction. This course Software Architecture with Java will discuss the following topics:

CSC 121 Computers and Scientific Thinking

Component Based Software Engineering

Chapter 10 Servlets and Java Server Pages

CSS Cascading Style Sheets

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

ITNP43: HTML Lecture 4

Web and Apps 1) HTML - CSS

Table of Contents. Introduction... xxi

Using Advanced Cascading Style Sheets

HTML. Based mostly on

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

HTTP and HTML. We will use HTML as a frontend to our webapplications, therefore a basic knowledge of HTML is required, especially in forms.

COMP201 Java Programming

Experiment No: Group B_2

Module 5 Developing with JavaServer Pages Technology

Transcription:

Trabalhando com JavaServer Pages (JSP) Sumário 7.2.1 Introdução 7.2.2 JavaServer Pages Overview 7.2.3 First JavaServer Page Example 7.2. Implicit Objects 7.2.5 Scripting 7.2.5.1 Scripting Components 7.2.5.2 Scripting Example 7.2. Standard Actions 7.2..1 <jsp:include> Action 7.2..2 <jsp:forward> Action 7.2.7 Directives 7.2.7.1 page Directive 7.2.7.2 include Directive 7.2. Referências sobre JSP 7.2.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 Paulo André Castro ITA Stefanini 3 Paulo André Castro ITA Stefanini 7.2.2 JavaServer Pages Overview Key components Directives Actions Scriptlets Tag libraries 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 Paulo André Castro ITA Stefanini 5 Paulo André Castro ITA Stefanini 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 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 Paulo André Castro ITA Stefanini 7 Paulo André Castro ITA Stefanini 1

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 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 Paulo André Castro ITA Stefanini 9 Paulo André Castro ITA Stefanini 50 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 7.2.3 A First JavaServer Page Example Simple JSP example (Fig. 7.2.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 Paulo André Castro ITA Stefanini 51 Paulo André Castro ITA Stefanini 52 5 <!-- Fig. 7.2.1: clock.jsp --> 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 9 <head> 10 <meta http-equiv = "refresh" content = "0" /> 11 12 <title>a Simple JSP Example</title> 13 1 <style type = "text/css"> 15.big { font-family: helvetica, arial, sans-serif; 1 font-weight: bold; 17 font-size: 2em; } 1 </style> 19 </head> 20 21 <body> 22 <p class = "big">simple JSP Example</p> 23 meta element refreshes the Web page every 0 seconds 2 <table style = "border: px outset;"> 25 <tr> 2 <td style = "background-color: black;"> 27 <p class = "big" style = "color: cyan;"> 2 29 <!-- JSP expression to insert date/time --> 30 <%= new java.util.date() %> 31 32 </p> 33 </td> 3 </tr> 35 </table> 3 </body> 37 3 </html> Creates Date object that is converted to a String implicitly and displayed in paragraph (p) element Paulo André Castro ITA Stefanini 53 Paulo André Castro ITA Stefanini 5 2

7.2. Implicit Objects Implicit Objects Provide access to many servlet capabilities within a JSP Four scopes Application scope Objects owned by the container application Any servlet or JSP can manipulate these objects Page scope Objects that exist only in page in which they are defined Each page has its own instance of these objects Request scope Objects exist for duration of client request Objects go out of scope after response sent to client Session scope Objects exist for duration of client s browsing session Objects go out of scope when client terminates session or when session timeout occurs Paulo André Castro ITA Stefanini 55 Paulo André Castro ITA Stefanini 5 Implicit object Application Scope application Page Scope config exception out page Description This javax.servlet.servletcontext object represents the container in which the JSP executes. This javax.servlet.servletconfig object represents the JSP configuration options. As with servlets, configuration options can be specified in a Web application descriptor. This java.lang.throwable object represents the exception that is passed to the JSP error page. This object is available only in a JSP error page. This javax.servlet.jsp.jspwriter object writes text as part of the response to a request. This object is used implicitly with JSP expressions and actions that insert string content in a response. This java.lang.object object represents the this reference for the current JSP instance. 7.2.5 Scripting Scripting Dynamically generated content Insert Java code and logic in JSP using scripting pagecontext This javax.servlet.jsp.pagecontext object hides the implementation details of the underlying servlet and JSP container and provides JSP programmers with access to the implicit objects discussed in this table. response This object represents the response to the client and is normally an instance of a class that implements HttpServletResponse (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a class that implements javax.servlet.servletresponse. Request Scope request This object represents the client request. The object normally is an instance of a class that implements HttpServletRequest (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a subclass of javax.servlet.servlet- Request. Session Scope session This javax.servlet.http.httpsession object represents the client session information if such a session has been created. This object is available only in pages that participate in a session. Fig. 25.2 JSP implicit objects. Paulo André Castro ITA Stefanini 57 Paulo André Castro ITA Stefanini 5 7.2.5.1 Scripting Components JSP scripting components Scriptlets (delimited by <% and %>) Comments JSP comments (delimited by <%-- and --%>) XHTML comments (delimited by <!-- and -->) Java s comments (delimited by // and /* and */) Expressions (delimited by <%= and %>) Declarations (delimited by <%! And %>) Escape sequences 7.2.5.1 Scripting Components (cont.) Literal Escape Description sequence <% <\% The character sequence <% normally indicates the beginning of a scriptlet. The <\% escape sequence places the literal characters <% in the response to the client. %> %\> The character sequence %> normally indicates the end of a scriptlet. The %\> escape sequence places the literal characters %> in the response to the client. ' \' As with string literals in a Java program, the escape " \" sequences for characters '," and \ allow these \ \\ characters to appear in attribute values. Remember that the literal text in a JSP becomes string literals in the servlet that represents the translated JSP. Fig. 7.2.3 JSP escape sequences. Paulo André Castro ITA Stefanini 59 Paulo André Castro ITA Stefanini 0 3

7.2.5.2 Scripting Example Demonstrate basic scripting capabilities Responding to get requests 5 <!-- Fig. 7.2.: welcome.jsp --> <!-- JSP that processes a "get" request containing data. --> 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 9 10 <!-- head section of document --> 11 <head> 12 <title>processing "get" requests with data</title> 13 </head> 1 15 <!-- body section of document --> 1 <body> 17 <% // begin scriptlet 1 Scriptlets used to 19 String name = request.getparameter( "firstname" ); insert Java code 20 21 if ( name!= null ) { 22 Use request implicit 23 %> <%-- end scriptlet to insert fixed template object to data get parameter --%> 2 Paulo André Castro ITA Stefanini 1 Paulo André Castro ITA Stefanini 2 25 <h1> 2 Hello <%= name %>, <br /> JSP expression 27 Welcome to JavaServer Pages! 2 </h1> 29 30 <% // continue scriptlet 31 32 } // end if 33 else { 3 35 %> <%-- end scriptlet to insert fixed template data --%> 3 37 <form action = "welcome.jsp" method = "get"> 3 <p>type your first name and press Submit</p> 39 0 <p><input type = "text" name = "firstname" /> 1 <input type = "submit" value = "Submit" /> 2 </p> 3 </form> 5 <% // continue scriptlet 7 } // end else 9 %> <%-- end scriptlet --%> 50 </body> 51 52 </html> <!-- end XHTML document --> Scriptlets used to insert Java code 7.2. Standard Actions JSP standard actions Provide access to common tasks performed in a JSP Including content from other resources Forwarding requests to other resources Interacting with JavaBeans JSP containers process actions at request time Delimited by <jsp:action> and </jsp:action> Paulo André Castro ITA Stefanini 3 Paulo André Castro ITA Stefanini 7.2. Standard Actions 7.2..1 <jsp:include> Action Action <jsp:include> <jsp:forward> <jsp:plugin> <jsp:param> JavaBean Manipulation <jsp:usebean> <jsp:setproperty> <jsp:getproperty> Fig. 25.5 JSP standard actions. Description Dynamically includes another resource in a JSP. As the JSP executes, the referenced resource is included and processed. Forwards request processing to another JSP, servlet or static page. This action terminates the current JSP s execution. Allows a plug-in component to be added to a page in the form of a browser-specific object or embed HTML element. In the case of a Java applet, this action enables the downloading and installation of the Java Plug-in, if it is not already installed on the client computer. Used with the include, forward and plugin actions to specify additional name/value pairs of information for use by these actions. Specifies that the JSP uses a JavaBean instance. This action specifies the scope of the bean and assigns it an ID that scripting components can use to manipulate the bean. Sets a property in the specified JavaBean instance. A special feature of this action is automatic matching of request parameters to bean properties of the same name. Gets a property in the specified JavaBean instance and converts the result to a string for output in the response. <jsp:include> action Enables content to be included in a JSP dynamically More flexible than include directive Requires more overhead when page contents change frequently Paulo André Castro ITA Stefanini 5 Paulo André Castro ITA Stefanini

7.2..1 <jsp:include> Action (cont.) Attribute page flush Fig. 25. Description Specifies the relative URI path of the resource to include. The resource must be part of the same Web application. Specifies whether the buffer should be flushed after the include is performed. In JSP 1.1, this attribute is required to be true. Action <jsp:include> attributes. <!-- banner to include in another document --> <div style = "width: 50px"> <p> Programação Orientada a Objetos <br /> Internet and World Wide Web Programming Training in Java<br /> ITA - Stefanini </p> <p> <a href = "mailto:pauloac@ita.br">pauloac@ita.br</a> </p> </div> Exemplo: include.jsp banner.html Paulo André Castro ITA Stefanini 7 Paulo André Castro ITA Stefanini <!-- contents to include in another document --> <p><a href = "http://www.comp.ita.br/~pauloac/"> Home Page </a></p> <p><a href = "http://www.ita.com.br"> ITA</a></p> <p><a href = "http://www.stefanini.com.br"> Stefanini </a></p> <p>send questions or comments about this site to <a href = "mailto:pauloac@ita.br"> pauloac@ita.br </a><br /> Copyright 2005 </p> toc.html 1 <!-- Fig. 7.2.9: clock2.jsp --> 2 <!-- date and time to include --> in another document 3 <table> 5 <tr> <td style = "background-color: black;"> 7 <p class = "big" style = "color: cyan; font-size: 3em; font-weight: bold;"> 9 10 <%-- script to determine client local and --%> 11 <%-- format date accordingly --%> 12 <% 13 // get client locale 1 java.util.locale locale = request.getlocale(); 15 1 // get DateFormat for client's Locale 17 java.text.dateformat dateformat = 1 java.text.dateformat.getdatetimeinstance( 19 java.text.dateformat.long, 20 java.text.dateformat.long, locale ); 21 22 %> <%-- end script --%> 23 2 <%-- output date --%> 25 <%= dateformat.format( new java.util.date() ) %> 2 </p> 27 </td> 2 </tr> 29 </table> clock2.jsp Use Locale to format Date with specified DateFormat Paulo André Castro ITA Stefanini 9 Paulo André Castro ITA Stefanini 70 5 <!-- Fig. 7.2.10: include.jsp --> 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 9 <head> 10 <title>using jsp:include</title> 11 12 <style type = "text/css"> 13 body { 1 font-family: tahoma, helvetica, arial, sans-serif; 15 } 1 17 table, tr, td { 1 font-size:.9em; 19 border: 3px groove; 20 padding: 5px; 21 background-color: #dddddd; 22 } 23 </style> 2 </head> 25 2 <body> 27 <table> 2 <tr> 29 <td style = "width: 10px; text-align: center"> 30 <img src = "images/logotiny.png" 31 width = "10" height = "93" 32 alt = "Deitel & Associates, Inc. Logo" /> 33 </td> 3 35 <td> 3 37 <%-- include banner.html in this JSP --%> 3 <jsp:include page = "banner.html" 39 flush = "true" /> 0 1 </td> 2 </tr> 3 <tr> 5 <td style = "width: 10px"> 7 <%-- include toc.html in this JSP --%> <jsp:include page = "toc.html" flush = "true" /> 9 50 </td> 51 Use JSP action to include banner.html Use JSP action to include toc.html Paulo André Castro ITA Stefanini 71 Paulo André Castro ITA Stefanini 72 5

52 <td style = "vertical-align: top"> 53 5 <%-- include clock2.jsp in this JSP --%> 55 <jsp:include page = "clock2.jsp" 5 flush = "true" /> 57 5 </td> 59 </tr> 0 </table> 1 </body> 2 </html> Use JSP action to include clock2.jsp 7.2..2 <jsp:forward> Action <jsp:forward> action Enables JSP to forward request to different resources Can forwarded requests only resources in same context <jsp:param> action Specifies name/value pairs of information Name/Value pairs are passed to other actions Paulo André Castro ITA Stefanini 73 Paulo André Castro ITA Stefanini 7 5 <!-- Fig. 7.2.11: forward1.jsp --> 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 9 <head> 10 <title>forward request to another JSP</title> 11 </head> 12 13 <body> 1 <% // begin scriptlet 15 1 String name = request.getparameter( "firstname" ); 17 1 if ( name!= null ) { 19 20 %> <%-- end scriptlet to insert fixed template data --%> 21 22 <jsp:forward page = "forward2.jsp"> 23 <jsp:param name = "date" 2 value = "<%= new java.util.date() %>" /> 25 </jsp:forward> 2 Forward request to forward2.jsp 27 <% // continue scriptlet 2 29 } // end if 30 else { 31 32 %> <%-- end scriptlet to insert fixed template data --%> 33 3 <form action = "forward1.jsp" method = "get"> 35 <p>type your first name and press Submit</p> 3 37 <p><input type = "text" name = "firstname" /> 3 <input type = "submit" value = "Submit" /> 39 </p> 0 </form> 1 2 <% // continue scriptlet 3 } // end else 5 %> <%-- end scriptlet --%> 7 </body> 9 </html> <!-- end XHTML document --> Paulo André Castro ITA Stefanini 75 Paulo André Castro ITA Stefanini 7 5 <!-- forward2.jsp --> 7 <html xmlns = "http://www.w3.org/1999/xhtml"v 9 <head> 10 <title>processing a forwarded request</title> 11 12 <style type = "text/css"> 13.big { 1 font-family: tahoma, helvetica, arial, sans-serif; 15 font-weight: bold; 1 font-size: 2em; 17 } 1 </style> 19 </head> Receive request from 20 forward1.jsp, then 21 <body> 22 <p class = "big"> get firstname 23 Hello <%= request.getparameter( "firstname" ) %>, <br /> parameter from request 2 Your request was received <br /> and forwarded at 25 </p> 2 27 <table style = "border: px outset;"> 2 <tr> 29 <td style = "background-color: black;"> 30 <p class = "big" style = "color: cyan;"> 31 <%= request.getparameter( "date" ) %> 32 </p> 33 </td> 3 </tr> 35 </table> 3 </body> 37 3 </html> Get date parameter from request Paulo André Castro ITA Stefanini 77 Paulo André Castro ITA Stefanini 7

7.2.7 Directives JSP directives Messages to JSP container Enable programmer to: Specify page settings Include content from other resources Specify custom-tag libraries Delimited by <%@ and %> 7.2.7 Directives (cont.) Directive Description page Defines page settings for the JSP container to process. include Causes the JSP container to perform a translationtime insertion of another resource s content. As the JSP is translated into a servlet and compiled, the referenced file replaces the include directive and is translated as if it were originally part of the JSP. taglib Allows programmers to define new tags in the form of tag libraries, which can be used to encapsulate functionality and simplify the coding of a JSP. Fig. 25.17 JSP directives. Paulo André Castro ITA Stefanini 79 Paulo André Castro ITA Stefanini 0 7.2.7.1 page Directive 7.2.7.1 page Directive (cont.) JSP page directive Specifies JSP s global settings in JSP container Attribute language extends import session Fig. 25.1 Description The scripting language used in the JSP. Currently, the only valid value for this attribute is java. Specifies the class from which the translated JSP will be inherited. This attribute must be a fully qualified class name. Specifies a comma-separated list of fully qualified type names and/or packages that will be used in the current JSP. When the scripting language is java, the default import list is java.lang.*, javax.servlet.*, javax.servlet.jsp.* and javax.servlet.http.*. If multiple import properties are specified, the package names are placed in a list by the container. Specifies whether the page participates in a session. The values for this attribute are true (participates in a session the default) or false (does not participate in a session). When the page is part of a session, implicit object session is available for use in the page. Otherwise, session is not available, and using session in the scripting code results in a translation-time error. Attributes of the page directive. Paulo André Castro ITA Stefanini 1 Paulo André Castro ITA Stefanini 2 7.2.7.1 page Directive (cont.) Attribute Description buffer Specifies the size of the output buffer used with the implicit object out. The value of this attribute can be none for no buffering, or a value such as kb (the default buffer size). The JSP specification indicates that the buffer used must be at least the size specified. autoflush When set to true (the default), this attribute indicates that the output buffer used with implicit object out should be flushed automatically when the buffer fills. If set to false, an exception occurs if the buffer overflows. This attribute s value must be true if the buffer attribute is set to none. isthreadsafe Specifies if the page is thread safe. If true (the default), the page is considered to be thread safe, and it can process multiple requests at the same time. If false, the servlet that represents the page implements interface java.lang.singlethreadmodel and only one request can be processed by that JSP at a time. The JSP standard allows multiple instances of a JSP to exists for JSPs that are not thread safe. This enables the container to handle requests more efficiently. However, this does not guarantee that resources shared across JSP instances are accessed in a thread-safe manner. info Specifies an information string that describes the page. This string is returned by the getservletinfo method of the servlet that represents the translated JSP. This method can be invoked through the JSP s implicit page object. Fig. 7.2.1 Attributes of the page directive. 7.2.7.1 page Directive (cont.) Attribute Description errorpage Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception. iserrorpage Specifies if the current page is an error page that will be invoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references the original exception that occurred. If false (the default), any use of the exception object in the page results in a translationtime error. contenttype Specifies the MIME type of the data in the response to the client. The default type is text/html. Fig. 25.1 Attributes of the page directive. Paulo André Castro ITA Stefanini 3 Paulo André Castro ITA Stefanini 7

Exercício Criar um programa JSP que liste o nome dos autores cadastrados no banco de dados: books.fdb Utilize o programa exemplo FirstJDBCProgram como base 7.2.9 Referências sobre JSP JSP at Sun Microsystems java.sun.com/products/jsp Servlets at Sun Microsystems java.sun.com/products/servlet J2EE at Sun Microsystems java.sun.com/j2ee Core Servlets and JavaServer Pages, Martin Hall, Sun Press Paulo André Castro ITA Stefanini 5 Paulo André Castro ITA Stefanini