Presentation is loading. Please wait.

Presentation is loading. Please wait.

JSP Directive and Objects. JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action.

Similar presentations


Presentation on theme: "JSP Directive and Objects. JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action."— Presentation transcript:

1 JSP Directive and Objects

2 JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action Elements We will be learning about JSP Directives

3 What are Directives Q. What are directive? Ans. Directives give directions or messages. In JSP, directive give directions to the JSP Container. Directive tell JSP Container how to translate a JSP page into Servlet

4 Types of Directive OR Where directive is the name of directive. There are 3 types of Directive in JSP 1.Page Directives - 2.Include Directives - 3.Tag Library Directives – For creating custom tags.

5 Page directive: Syntax for using page directive is So what all attributes are available?

6 Attributes of page directive The following attributes can be used with page directive info contentType pageEncoding language import session buffer autoFlush errorPage isErrorPage

7 Attribute info of page directive Syntax -This attribute is not important. - It is just a text string informing the purpose of JSP page.

8 Attribute contentType of page directive contentType specifies the kind of data returned by browser. A browse can return text, html, xml. By default But if you write a program where browser returns xml, then

9 Attribute pageEncoding of page directive pageEncoding is used if you want to display characters of some other language. For ex: If you develop a web site that is in hangul, and I open that web site from an english computer In that case, browser would not display characters properly But if I use pageEncoding then browser will display characters propertly Syntax:

10 Attribute language of page directive Language –Is used to specify the scripting language. –By default is is Java. You can use javascript also In that case

11 Attribute import of page directive import It is very important In previous example,I used Calendar class In another example, I used Enumerator class. When I used Enumerator class, I wrote java.util.Enumerator If I use <%@ page import=“java.util.*”, then I can use only Enumerator in JSP page.

12 Attribute session of page directive session –This attribute is used to specify the scope of objects and variables. Syntax Default value of session attribute is true. We will use session attribute with JavaBeans.

13 Attribute errorPage and isErrorPage of page directive errorPage attribute tells the JSP which page to display when an error occurs. If there is no errorPage used, then the error are displayed. But If we want, we can display a custom error page. Custom error page will display error in a beautiful manner.

14 Continued…. Syntax If I use this statemetn in my JSP file, then If any error occurs, handleError.jsp will be displayed on browser.

15 isErrorPage errorPage and isErrorPage are used together. The web page handleError.jsp first line will be This means, handleError.jsp is an error page. It will be displayed when an error occurs.

16 Example of errorPage and isErrorPage Code of ErrorPage.jsp Error An error occurred while processing your request. The error message is:. </html

17 Continued SourceCode for hello.jsp <% String str = new Sring(“hello”); %> This is wrong, therefore ErrorPage.jsp should be displayed


Download ppt "JSP Directive and Objects. JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action."

Similar presentations


Ads by Google